Get Started

From install to first test run in three steps.

01

Installation

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).

Install from PyPI

  1. From your terminal: pip install test-junkie or python -m pip install test-junkie
  2. You are done and ready to go!

To upgrade: pip install test-junkie --upgrade

To uninstall: pip uninstall test-junkie

02

Test Definition

Lets get you started with some initial test definitions. Save code bellow into a local Python file. Lets say C:\Development\MyTests\demo.py.

demo.pypython
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")
03

Test Execution

There are two possible ways to run tests on Test Junkie. Both are fully configurable!

  1. Programmatically - allows to invoke the tests anywhere in your code
  2. Test Junkie CLI - allows to run tests without any additional code required

Gives you flexibility to build a wrapper around Test Junkie to support use cases it may not support out of the box.

demo.pypython
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 card: thumbnail of the HTML report + label, title, text, button. Styles: .demo-cta in static_src/components.css. with: text="…" (required), compact=True for a smaller thumbnail (Get Started), title="…" (default "Click through a real report"). #}
Test Junkie HTML report: summary stats, CPU and memory chart, and a test's detail panel showing its metadata and two attempts

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 →