Simple System Tests Environment.
Project description
simple-system-tests
Simple Python library for writing test cases for System and components tests including automatic reports via html. The intention is to have an easy framework for developers without the need to learn a separate coding language. Check out the repository via:
git clone https://github.com/chrisKoeh/simple-system-tests.git
(Optional) Build package locally
pip3 install setuptools wheel
python3 setup.py sdist bdist_wheel
(sudo) python3 setup.py install
Installation
pip3 install simple-system-tests
Quick-Start
Go to examples
and run:
python3 main.py
which will execute several testcases with different parameters. An error message will be printed, that a system_params.json
was not found
which can be ignored for now. After that open the created examples/index.html
for an overview
of the results in a web browser.
Testsuite
The Testsuite is defined under simple_system_tests/TestSuite.py
:
- holds and executes testcases
- prepare and teardown of Testsuite, which can be implemented by using decorators(optional):
import simple_system_tests as sst
@sst.prepare_suite
def s_prepare(self):
self.logger.info("preparing the suite")
@sst.teardown_suite
def s_teardown(self):
self.logger.info("tearing the suite down")
- reporting of test results stored in
index.html
(can be configured via command line) - providing command line options for configurations and all testcases allowing them to be called separately
Command line options
When using a Testsuite command line options for all testcases added to the suite will be
automatically created. Command line option shortcut will be
derived from the beginning characters of the description string passed to the testcase.
So make sure to have varying descriptions for your testcases. Having a look at the help of
examples/main.py
again will give the following output:
shell: python3 main.py -h
usage: main.py [-h] [-no] [-p JSON_SYSTEM_PARAMS] [-o REPORT_OUTPUT] [-ht] [-ho]
optional arguments:
-h, --help show this help message and exit
-no, --no-suite-setup
No Suite Prepare and Teardown
-p JSON_SYSTEM_PARAMS, --json-system-params JSON_SYSTEM_PARAMS
Path to JSON params file.
-o REPORT_OUTPUT, --report-output REPORT_OUTPUT
Path to report html file.
-ht, --http_get Test Http get
-ho, --host_unix_time
Test Host unix time
-s, --simple_print Test Simple print
-m, --multi_prints Test multi prints
-r, --retries Test retries
-t, --timeouted Test timeouted
So testcases can be called separately without having to execute all testcases in one run.
It is also possible to pass multiple testcases in one execution. In case the Suite setup and
teardown is not wanted this can be achieved by putting the -no, --no-suite-setup
option.
Testcases
Create new testcases
Testcases are created using decorators:
import simple_system_tests as sst
@sst.testcase("Custom testcase")
def custom_testcase(self):
raise Exception("Fails always, anyways")
A testcase is considered PASS
as long as no exception is raised.
Testcase arguments
@sst.testcase(desc, sub_params=[], retry=0, timeout=-1, prepare_func=None, teardown_func=None)
- desc: description of testcase, which will be used to create according command line option
- sub_params: allows testcase to be called multiple times with count of sub_params length.
- retry: how often a testcase is retried before considered as
FAIL
- timeout: in seconds how long the testcase may last, considered as
FAIL
if extended - prepare_func / teardown_func: functions to be called before / after testcase execution
System parameters
Environment parameters for the testsuite can be used from a json file named system_params.json
(the file path can be customized by passing the -p
option). Those will be made available in the
Testcase by the attribute self.params
:
import simple_system_tests as sst
@sst.testcase("case with env params")
def env_testcase(self):
self.logger.info(self.params)
It is also possible to access and modify these json params from within the testsuite, eg. in case a global python object should be made available in Testsuite preparation for all testcases.
Logging
The file path of the output file can be customized by passing the -o
option, which defaults to
index.html
. A logger
object attribute is available within testcases and testsuites.
However stdout is mapped to logger.info
, hence print
can also be used directly which will
result in output of both console and html report file as INFO
message.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file simple-system-tests-0.2.0.tar.gz
.
File metadata
- Download URL: simple-system-tests-0.2.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2107e2eb5c1a946b76adbefe1a56b82dfee389c3f80cadc78cab577dfffb3e47 |
|
MD5 | c98985219f1bfecd3e23c009d1d8850c |
|
BLAKE2b-256 | d511bfeac6e1cc4d1f8eba247e8085cbef5af1ccb2ff850234730401a2aa09ea |
File details
Details for the file simple_system_tests-0.2.0-py3.7.egg
.
File metadata
- Download URL: simple_system_tests-0.2.0-py3.7.egg
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22ca664010938d11c56659c4bdd86ae3a80929f32d1468f6b9085daa5cbfe8a5 |
|
MD5 | 49f2c38541d28817a5c2591b528a337f |
|
BLAKE2b-256 | fb9235e5744aed7876cad42447e80e5be1f597256e91b3d9d4c950be1c73adef |
File details
Details for the file simple_system_tests-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: simple_system_tests-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3089d87c2d4178de783cec7e8eb60ddac16397c9a91b8c9eaf06259fb826a76f |
|
MD5 | e619391bbf7fc7d2b2e5330e01ab36cc |
|
BLAKE2b-256 | 64f8c131ab683c8cd30791b524b8e7b2e4d19890cbd84cef0a5c1fc417f83590 |