Test Class

In order to use test classes in your project, you need the tapir-execution module.

<dependency>
    <groupId>de.bmiag.tapir</groupId>
    <artifactId>tapir-execution</artifactId>
</dependency>

Structure

A test class (annotated with @TestClass) is an executable unit which contains at least one step. All the steps (annotated with @Step) declared in a test class are executed sequentially. The most simple test class looks like this:

@TestClass
class MyTest {
    @Step
    def void step1() {
        println("Step 1 is executed")
    }
}

Using Page Objects

Test classes should use page objects to interact with the SUT. Like any other Spring bean these page objects can be autowired by using Spring’s @Autowire annotation. You can find additional information about page objects in the dedicated chapter.

Hint
You can inject any bean by using @Autowired. This capability is not limited to page objects.
@TestClass
class MyTest {
 
    @Autowired
    MyPage myPage

    @Step
    def void step1() {
        myPage.textField.text = "Test"
    }
}

Extensions

In every Test class TapirAssertions is registered and all its visible members can be used in the test class:

@TestClass
class MyTest {
 
    @Autowired
    MyPage myPage

    @Step
    def void step1() {
        assertThat(myPage.textField.text, is("Test"))
    }
}

You can add custom extensions by using @UseExtension.

Documentation

Test classes can and should be documented. There is a dedicated chapter about Documentation.