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.


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.


class MyExecutionFilter implements ExecutionFilter {

    override shouldFilterSuite(TestSuite testSuite, Object testInstance) {

    override shouldFilterClass(TestClass testClass, Object testInstance) {

    override shouldFilterStep(TestStep testStep, Object testInstance) {

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.

Keep in mind that you cannot "unfilter" an element. If at least one registered filter wants to filter an element out, it is removed from the execution plan.