Skip to main content

This modules allows you to execute tests in the best way possible!

Project description

Test Executor

Introduction

This module allows you to execute tests in serial and parallel mode. A test's flow defined by this module is as follows:

  • setup - general configurations for starting th test
  • pre_test - this should be defined specifically per test class if needed
  • test - the test logic itself
  • post_test - same as for pre_test
  • cleanup - cleans what is needed after the test's flow is done

Main one can create a general test class that will implement the "setup" and "cleanup" steps, let other test classes inherit from it and then implement any specific logic for pre_test and/or post_test if needed.

Testing Example

Tests execution

Test execution can be done as follows:

# Load the tests needed from a list of paths
loaded_tests = TestLoader.load_tests(test_paths)

# Creating a new test executor with the required concurrency level
test_executor = TestExecutor(concurrency_level=concurrency)

# Starting the execution and getting the results
test_executor.Logger.info("*" * 32 + " Start Execution " + "*" * 32)
results = test_executor.execute(loaded_tests, listener=listener)
test_executor.Logger.info("*" * 32 + " End Execution " + "*" * 32)

Tests implementation

The following is an example for a basic class implementation, as you can also see a fully configured logger is available during the execution:

from test_executor.abstract_test.abstract_test import AbstractTest
class ExampleTest(AbstractTest):
    def setup(self):
        self.logger.info(f"Setup 1")

    def cleanup(self):
        self.logger.info(f"Cleanup 1")

    def test_1(self):
        self.logger.info(f"Test 1")

    def test_2(self):
        self.logger.info(f"Test 2")

The logger available is configured separately for each test, so that each test will have their own logs. Logs will be saved be default under a "logs" folder in the current working directory. Each execution that contains 1 test or more will generate a logs folder in the following format:

{DAY}-{MONTH}-{YEAR}_{HOUR}-{MINUTE}-{SECOND}-{MICROSECONDS}

Under this folder each test will create its own test folder in the following format:

{TEST_NUMBER}_{TEST_CLASS_NAME}.{TEST_METHOD_NAME}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

test_executor-0.0.12.tar.gz (9.0 kB view details)

Uploaded Source

File details

Details for the file test_executor-0.0.12.tar.gz.

File metadata

  • Download URL: test_executor-0.0.12.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.0.1 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0

File hashes

Hashes for test_executor-0.0.12.tar.gz
Algorithm Hash digest
SHA256 eada88d92b72437db81a505eccebe5bb261bcb5bc0f538adcb49ce5afc6dd7bb
MD5 c29d2a72e3f8d6b89ad230f8dc9b701d
BLAKE2b-256 f6d965ff9888a7f89c96485a9484ec0c5204a4db20ceb778c9b34864f0239e12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page