TT#74160 Allow reuse of API TestFramework object

Allow reusing previously created NGCP::API::TestFramework object for
running a new test scenario, while using previously collected data.
- Save 'retained' variables inside module $self object.
- Move 'unique_id' generation from the module to wrapper script.
- Allow rewriting of 'file_path' object.

Change-Id: Ie961f7d0fb34f71e04353125e026ad00715efe91
changes/43/37343/5
Victor Tsvetov 6 years ago
parent c64a645027
commit 8655f073d2

@ -23,6 +23,11 @@ use NGCP::API::TestFramework::Client;
use NGCP::API::TestFramework::TestExecutor;
has 'file_path' => (
isa => 'Str',
is => 'rw'
);
has 'unique_id' => (
isa => 'Str',
is => 'ro'
);
@ -71,8 +76,9 @@ sub run {
INFO( "Setting up the Test Executor." );
my $test_executor = NGCP::API::TestFramework::TestExecutor->new();
# initializing time to add to fields which need to be unique
my $retained = { unique_id => int(rand(100000)) };
# If $self->{retained} is already defined, use its previously collected variables.
# Otherwise, initialize it with received "unique_id" for fields that need to be unique.
my $retained = $self->{retained} //= { unique_id => $self->unique_id };
my $test_case_result = { success => 1, error_count => 0 };

@ -73,7 +73,10 @@ sub worker {
chomp $test_file;
my $start_time = time;
print "Running tests from $test_file\n";
my $test_framework = NGCP::API::TestFramework->new( {file_path => $test_file} );
my $test_framework = NGCP::API::TestFramework->new( {
file_path => $test_file,
unique_id => int(rand(100000)),
} );
my $result = $test_framework->run();

Loading…
Cancel
Save