Ward: A new Python package for software testing

written by Eric J. Ma on 2021-05-29 | tags: til software testing tooling

Today I learned about a new package called Ward. It claims to be an alternative to pytest with a focus on productivity and readability.

Looking at the examples on the docs, I see a few cool things that are in there:

def three():
    yield 3

@test("{a} + {b} == {result}")
def _(a=1, b=2, result=three):
    assert a + b == result

@test("simple addition", tags=["unit", "regression"])
def _():
    assert 1 + 2 == 3

Firstly, how the @test decorator is used to provide a descriptive name, thus allowing us to completely bypass trying to think up descriptive test function names and instead simply describe the test in plain English. I can see how this makes documenting the test a little bit easier.

Secondly, how tags (which in pytest land would be marks) are simply added as part of the @test decorator.

The syntax is definitely attractive. That said, while I like the syntax, one thing that might prevent me from using ward at this moment in time is the lack of clarity with how it interfaces with hypothesis, which I use to do testing of machine learning model implementations. I might do some digging in the near future. For now, just leaving this note here for future reference.