Tutorials / Recipes

Fast feedback loops

Two independent levers get you a quick answer from a large suite: running only the tests that matter right now, and running more of them at once.

This isn't load testing
Test Junkie doesn't generate load or measure your application's performance; it's a test runner. This is about your own suite's speed: running a smaller, targeted slice of it, in parallel, so you know in seconds instead of minutes.

1. Label tests as you write them

feature is set on the suite, component and tags on tests, owner on either. None of it changes how a test runs; it's what you filter on later.

test_checkout.pypython
from test_junkie.decorators import Suite, test


@Suite(feature="Checkout", owner="checkout-team")
class CheckoutSuite:

    @test(component="Payments", tags=["smoke", "critical-path"], priority=1)
    def apply_discount_code(self):
        ...

    @test(component="Shipping", tags=["regression"], priority=3)
    def calculate_shipping_cost(self):
        ...

2. Run only what matters right now

On the command line, pick the slice by tag, component, owner or test name, and raise the thread limits:

terminalbash
# smoke tests only, 8 test threads, 4 suites at once
tj run -k smoke -T 8 -S 4

# just the payment tests you're working on, run once each (no retries)
tj run -c Payments --no-retry

# tests by name or pattern
tj run -t "apply_*" CheckoutSuite.calculate_shipping_cost

The same from Python:

run_smoke.pypython
from test_junkie.runner import Runner

Runner([CheckoutSuite]).run(
    tag_config={"run_on_match_any": ["smoke"]},
    test_multithreading_limit=8,
    suite_multithreading_limit=4,
)

3. Save the settings you always use

Save the sources and thread limits once in a tj.cfg at the root of the project, commit it, and tj run from anywhere in the project uses it:

terminalbash
tj config update -s tests -T 8 -S 4 --config ./tj.cfg
tj run -k smoke    # sources and threads come from tj.cfg
Filter first, then parallelize
Raising thread limits on an unfiltered suite still runs everything, just faster; it doesn't replace picking the right subset. Filter down to the tests this loop needs, then raise the limits on what's left. tj run -m shows how many tests actually ran at once, so you can tell when more threads stop helping.