Skip to content
GitHub

Annotate your Testcases

This guide shows you how to annotate your tests with Allure metadata and organize them with steps.

Test group (suite) metadata applies to all tests within that group. The approach differs between GoogleTest and CppUTest.

Use SetUpTestSuite() to configure suite-level metadata:

class CalculatorTests : public ::testing::Test {
protected:
    static void SetUpTestSuite() {
        suite()
            .name("Calculator Test Suite")
            .description("Tests for basic arithmetic operations")
            .epic("Calculator Module")
            .severity("critical");
    }
};

Call test() at the start of each test to set test-specific metadata like name, feature, and story.

TEST_F(CalculatorTests, AdditionTest) {
    test()
        .name("Verify addition of two numbers")
        .feature("Arithmetic Operations")
        .story("User can add two numbers")
        .severity("critical");

    int result = 2 + 3;
    EXPECT_EQ(5, result);
}

Use the step() function to organize test logic into named steps that appear in the Allure report. Steps accept a lambda function and automatically manage their lifecycle.

TEST_F(CalculatorTests, MultiStepTest) {
    test()
        .name("Multi-step calculation")
        .feature("Arithmetic Operations");

    int result = 0;

    step("Initialize value to 5", [&]() {
        result = 5;
    });

    step("Add 3 to value", [&]() {
        result += 3;
    });

    step("Verify result is 8", [&]() {
        EXPECT_EQ(8, result);
    });
}

You can also use RAII-style steps without lambdas:

TEST_F(CalculatorTests, RAIIStyleSteps) {
    test().name("RAII-style steps example");

    int result = 0;

    {
        auto s = step("Initialize value");
        result = 5;
    }

    {
        auto s = step("Multiply by 2");
        result *= 2;
    }

    EXPECT_EQ(10, result);
}
  • .name(string) - Suite name
  • .description(string) - Suite description
  • .epic(string) - Epic classification
  • .severity(string) - Severity level: “blocker”, “critical”, “normal”, “minor”, “trivial”
  • .label(key, value) - Custom label
  • .name(string) - Test name
  • .description(string) - Test description
  • .feature(string) - Feature classification
  • .story(string) - User story
  • .severity(string) - Severity level
  • .label(key, value) - Custom label
  • .flaky() - Mark test as flaky
  • .known() - Mark test as known issue
  • .muted() - Mark test as muted