-
Changes in Version 3.6.2 (2021-01-22)
Changes in Version 3.5.0 (2020-06-04)
Changes in Version 3.4.2 (2020-03-26)
Changes in Version 3.3.1 (2019-08-22)
Changes in Version 3.3.0 (2019-01-09)
Changes in Version 3.2.1 (2018-12-21)
Changes in Version 3.2.0 (2018-08-27)
Changes in Version 3.1.1 (2018-06-29)
Changes in Version 3.1.0 (2018-03-27)
Changes in Version 3.0.0 (2018-02-20)
Execution Filter
Before tapir starts the test cases, a execution plan is assembled by the TapirExecutor. This is also described in the chapter How does it work?. Before the plan is actually executed, various filters can decide whether steps, classes or suites should be filtered out. This is especially useful when you want to make sure that specific elements are not executed and are not even visible in the test report in the first place.
<dependency>
<groupId>de.bmiag.tapir</groupId>
<artifactId>tapir-execution</artifactId>
</dependency>
As you might remember, some previous features of tapir were able to remove elements from the execution plan: The @FeatureActivatedannotation from the variant management chapter, the @Conditionalannotation from the conditional chapter and so on. Well, they all use the same mechanism as described in this chapter.
In order to filter elements out, you have to create a class which implements the interface ExecutionFilter. Also Spring must be aware of your component. A very simple filter (which does not filter out anything) would look like the following.
MyExecutionFilter.xtend
@Component
class MyExecutionFilter implements ExecutionFilter {
override shouldFilterSuite(TestSuite testSuite, Object testInstance) {
false
}
override shouldFilterClass(TestClass testClass, Object testInstance) {
false
}
override shouldFilterStep(TestStep testStep, Object testInstance) {
false
}
}
For each of the three test elements (test suites, test classes and test steps), the filter can decide whether the element should be removed from the test plan or not. For this purpose, the filter gets the corresponding model element and the concrete test instance. Now you can probably imagine how the Conditional filtering is actually implemented. The ConditionalFilter searches for an Conditional annotation at the respective element, retrieves the conditional provider, as well as the conditional method and invokes it. If the method returns false, the element is filtered out. The other listeners in tapir, the FeatureActivatedAnnotationFilterand the FeatureBasedParameterFilter, work in a similar manner.
- Previous
- Next