APP-REST-RestTestSuite

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

    dist_abstract       => 'rest-client => Test automation tool for restful web services',
    release_status      => 'stable',
    script_files      => [
        'script/rest-client', 
    ],
    meta_merge        => {
        resources => {
            repository => 'https://github.com/rkmithun/APP-REST-RestTestSuite'
        }
    },
    configure_requires => {
        'Module::Build' => 0,
    },
    build_requires => {
        'Test::More' => 0,
    },
    requires           => {
        'LWP::Parallel::UserAgent' => 0,
        'LWP::UserAgent'           => 0,
        'HTTP::Request'            => 0,
        'File::Path'               => 0,

META.json  view on Meta::CPAN

      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
      "version" : "2"
   },
   "name" : "APP-REST-RestTestSuite",
   "prereqs" : {
      "build" : {
         "requires" : {
            "Test::More" : "0"
         }
      },
      "configure" : {
         "requires" : {
            "Module::Build" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "File::Basename" : "0",
            "File::Path" : "0",
            "Getopt::Long" : "0",
            "HTTP::Request" : "0",

META.yml  view on Meta::CPAN

---
abstract: 'rest-client => Test automation tool for restful web services'
author:
  - 'Mithun Radhakrishnan <rkmithun@cpan.org>'
build_requires:
  Test::More: 0
configure_requires:
  Module::Build: 0
dynamic_config: 1
generated_by: 'Module::Build version 0.4206, CPAN::Meta::Converter version 2.120921'
license: artistic_2
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: APP-REST-RestTestSuite
provides:
  APP::REST::ParallelMyUA:

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN


sub validate_test_cases {
    my ($self) = shift;

    my $err = undef;

    unless (@_) {
        $err = "There is no test cases defined to execute.\n";
    } elsif ( ( (@_) % 2 ) == 1 ) {
        $err =
            "Test cases are not properly configured in '"
          . $self->get_config_file()
          . "'\nDefine test cases properly.\nPlease see the README file for more info.\n";
    }
    return $err if ($err);

    my %test_cases = @_;

    my @spec = sort qw(
      test_case
      uri

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

        }

    }
    close($fh);
}

sub _init_rest_base_uri {
    my ( $self, %args ) = @_;

    if ( $self->{username} ) {
        print STDERR "username configured: $self->{username}\n";
        print STDERR "Password: ";
        chomp( $self->{password} = <STDIN> );
    }

    if ( $self->{endpoint} && $self->{port} && $self->{base_uri} ) {
        $self->{rest_uri_base} =
            qq|http://$self->{endpoint}|
          . qq|:$self->{port}|
          . qq|$self->{base_uri}|;
        return;    #use the port and uri in config file and return from sub

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

          qq|http://$self->{endpoint}| . qq|$self->{base_uri}|;
        return;    #use the uri in config file and return from sub
    } elsif ( $self->{endpoint} && $self->{port} ) {
        $self->{rest_uri_base} =
          qq|http://$self->{endpoint}| . qq|:$self->{port}|;
        return;
    } elsif ( $self->{endpoint} ) {
        $self->{rest_uri_base} = qq|http://$self->{endpoint}|;
        return;    #use the endpoint in config file and return from sub
    } else {
        die qq|Endpoint should be configured in the config file\n|;
    }

}

sub _init_config_files {
    my ( $self, %args ) = @_;

    $self->{file}->{config_file} = $args{REST_CONFIG_FILE};
}

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

# Every test case should be within the '#START_TEST_CASE' and '#END_TEST_CASE' block.
# Create application specific config file in below format and pass the 
# full path of file as an argument to the constructor
# for POST and PUT methods you need to supply the request body within
# [START] and [END] tags
#   request_body             :
#   [START] 
#   xml or json or  form based 
#   [END]
################
#Set below values to configure the base URL for all test cases

####################
#START_COMMON_CONFIG
################################################################################
  endpoint                  : www.thomas-bayer.com 
  port                      :
  base_uri                  : /sqlrest 
  html_log_required         : no 
  username                  : 

script/rest-client  view on Meta::CPAN

Usage: $client [options] command [...]

Options:
  -h,--help                 Display this usage. 
  -V,--version              Print the version of the tool. 
  -c,--configfile=<file>    Input the config file with full path.
  -l,--logdir=<dir>         Input full path of the directory where you want to log the test results.
  -t,--test-load=n          Test the average response time by simulating 'n' number of requests on the web server.

Commands:
  -r,--run-test-suite       Test the configured web services defined in the config file.
  -g,--get-sample-config    Get a sample config file to configure your web services as test suite. 

***Note: 
By default tool uses the sample-config file. You need to get that and configure the suite.

Examples:
  $client --get-sample-config           
                # Get sample config file for configuring web services in the current directory.

  $client --run-test-suite --configfile=<rest_config_file> 
                # Execute the test suite against the supplied config file. 
                # Supply the full path of config file if it is not present in current directory.

  $client --test-load=10 --configfile=<rest_config_file> 
                # Send parallel requests (10* number of web services configured in config file). 
                # Give average response time by simulating huge traffic in the web server.

  $client --run-test-suite --configfile=<rest_config_file>  --logdir=<log-directory-path>
  $client --test-load=10   --configfile=<rest_config_file>  --logdir=<log-directory-path>
                # Create LOG files in the path specified by executing the test cases. 

HELP
    exit;
}

script/rest-client  view on Meta::CPAN

    $suite = new APP::REST::RestTestSuite( LOG_FILE_PATH => $log_dir, );

} else {
    unless ( $action->{getsampleconfig} ) {
        print <<HELP;
  Using the default test suite. This is just for a demo purpose.
  Use below options to specify the config file and log path.

  $client --configfile=<rest_config_file> --logdir=<log-directory-path>

  Use below option to get a sample config. Edit the config file to configure your web services

  $client --get-sample-config

HELP
    }
    $suite = new APP::REST::RestTestSuite();
}

if ( $action->{debug} ) {

    print Dumper $suite;
    exit;

} elsif ( $action->{runtestsuite} ) {

    $suite->execute_test_cases( $suite->get_test_cases() );
    my ( $config, $total, $skip, $pass, $fail ) = $suite->get_result_summary();
    print "=" x 70, "\n";
    print "Summary of web service Suite    \n";
    print "=" x 70, "\n";
    print "Total test cases configured : $config\n";
    print "Total test cases executed   : $total\n";
    print "Total test cases skipped    : $skip\n";
    print "Total test cases pass       : $pass\n";
    print "Total test cases failed     : $fail\n";
    print "=" x 70, "\n";
    exit;

} elsif ( $action->{testload} ) {

    die "--test-load accepts only numeric argument\n"

script/rest-client  view on Meta::CPAN

    print "=" x 70, "\n";
    print "Total test cases in config: $config\n";
    print "Total test cases executed : $total\n";
    print "Total test cases skipped  : $skip\n";
    print "=" x 70, "\n";
    exit;

} elsif ( $action->{getsampleconfig} ) {

    $suite->get_sample_test_suite();
    print "Sample Config file to configure the web services got created\n";
    print "in ", $suite->get_sample_config_file(), "\n";
    print "Edit and rename this file as project specific test suite.\n\n";
    exit;

} else {

    print "\nUse below options to execute the test cases\n\n";
    print "$client --configfile=<rest_config_file> --run-test-suite\n\n";
    exit;

script/rest-client  view on Meta::CPAN

Usage: rest-client [options] command [...]

Options:
  -h,--help                 Display this usage. 
  -V,--version              Print the version of the tool. 
  -c,--configfile=<file>    Input the config file with full path.
  -l,--logdir=<dir>         Input full path of the directory where you want to log the test results.
  -t,--test-load=n          Test the average response time by simulating 'n' number of requests on the web server.

Commands:
  -r,--run-test-suite       Test the configured web services defined in the config file.
  -g,--get-sample-config    Get a sample config file to configure your web services as test suite. 

***Note: 
By default tool uses the sample-config file. You need to get that and configure the suite.

Examples:
  rest-client --get-sample-config           
                # Get sample config file for configuring web services in the current directory.

  rest-client --run-test-suite --configfile=<rest_config_file> 
                # Execute the test suite against the supplied config file. 
                # Supply the full path of config file if it is not present in current directory.

  rest-client --test-load=10 --configfile=<rest_config_file> 
                # Send parallel requests (10* number of web services configured in config file). 
                # Give average response time by simulating huge traffic in the web server.

  rest-client --run-test-suite --configfile=<rest_config_file>  --logdir=<log-directory-path>
  rest-client --test-load=10   --configfile=<rest_config_file>  --logdir=<log-directory-path>
                # Create LOG files in the path specified by executing the test cases. 


=head1 SEE ALSO
 
L<https://github.com/rkmithun/APP-REST-RestTestSuite>



( run in 0.388 second using v1.01-cache-2.11-cpan-283623ac599 )