From install to first test run in three steps.
In order to install Test Junkie you need to have Python installed. Test Junkie supports Python 3.9 through the latest stable release (see the CI test matrix for the exact current list).
pip install test-junkie or python -m pip install test-junkieTo upgrade: pip install test-junkie --upgrade
To uninstall: pip uninstall test-junkie
Lets get you started with some initial test definitions.
Save code bellow into a local Python file. Lets say
C:\Development\MyTests\demo.py.
from test_junkie.decorators import Suite, beforeTest, afterTest, test, beforeClass, afterClass @Suite() class ExampleTestSuite: @beforeClass() def before_class(self): print("Hi, I'm optional before class") @beforeTest() def before_test(self): print("Hi, I'm optional before test") @afterTest() def after_test(self): print("Hi, I'm optional after test") @afterClass() def after_class(self): print("Hi, I'm optional after class") @test() def something_to_test1(self): print("Hi, I'm test #1") @test() def something_to_test2(self): print("Hi, I'm test #2") @test() def something_to_test3(self): print("Hi, I'm test #3")
There are two possible ways to run tests on Test Junkie. Both are fully configurable!
Gives you flexibility to build a wrapper around Test Junkie to support use cases it may not support out of the box.
if "__main__" == __name__: from test_junkie.runner import Runner runner = Runner([ExampleTestSuite]) runner.run()
> python demo.py Test Junkie 0.9a6 · Python 3.12.5 · Windows 11 tests 1 suite, 3 tests mode sequential ExampleTestSuite demo.py [||||||||||||||||||||||||] 3/3 0.00s Total [||||||||||||||||||||||||] 3/3 100% 0.0s Summary ──────────────────────────────────────────────────────────────────────── Suite Pass Fail Error Ignore Skip Cancel Time ExampleTestSuite 3 · · · · · 0.00s ──────────────────────────────────────────────────────────────────── Total 3 · · · · · 0.01s 3 tests 100% ──────────────────────────────────────────────────────────────────────────────── PASSED
The runner object gives you access to test metrics after the run.
See JSON report for more info,
and Running tests in the documentation for every way to filter and run.
Live demo
Curious what a finished run looks like?
A real HTML report from a 0.9a8 run, as Test Junkie writes it: results by suite and test, retries, metadata and timings.
Open the live demo →