Steps

up

Here are informations about how you can improve long tests using steps.

Summary

About

Most of the time, the unit tests are short and simple. But when you have some complicated scenarios, like integration or UI tests, you might want to add more verbosity to your test. An example of such report is this: allure report

The Step structure helps you to add more information to your reports.

import trial.step;

unittest {
    Step("first step");
    // do something

    Step("the second step");
    // do something else
}

The previous example adds two steps to a test, which will be displayed by your reporter if it suports this feature.

Nested Steps

You can add nested steps if you store the step in a local variable:

import trial.step;

void someStep() {
    auto step2 = Step("the second step");
    // do something else
}

unittest {
    auto step1 = Step("first step");
    // do something

    someStep();
}

In this case, the step2 will have step1 as a parent.