Class DefaultAnnotationFilter

java.lang.Object
org.junit.runner.manipulation.Filter
de.hybris.platform.testframework.DefaultAnnotationFilter

public class DefaultAnnotationFilter extends org.junit.runner.manipulation.Filter
Filter is a tool which allow to exclude some test from the suite. The reason of creating such tool is to increase developers productivity by selecting which test should be run. The idea is to annotate all long-running tests with proper annotation (e.g. @PerformanceTest) and exclude them from execution during the development. If we remove these monsters from basic unit/integration tests we can try to run all tests before commit (all unit tests). It is very important to bring that possibility to mere developers again, because it is the foundation of test-driven development.

Configuration

You can configure filter setting these properties:
  • hybris.junit4.annotations.included - list of comma separated annotations; tests with these annotations will be included in the test
  • hybris.junit4.annotations.excluded - list of comma separated annotations; tests with these annotations will be excluded from the test
  • hybris.junit4.annotations.defaultIncluded - true or false; if true - all tests will be run except those with annotations from excluded list; if false - only tests with annotations from included list will be run (except those with annotations from excluded list); default value is true;
You must remember that excluded list has the priority over other settings. Therefore if at least one annotation of the test is on the excluded list test will be skipped.

Examples

Run only PerformanceTest and IntegrationTest
hybris.junit4.annotations.included=PerformanceTest,IntegrationTest
hybris.junit4.annotations.excluded=
hybris.junit4.annotations.defaultIncluded=false

Run all tests without PerformanceTest
hybris.junit4.annotations.included=
hybris.junit4.annotations.excluded=PerformanceTest
hybris.junit4.annotations.defaultIncluded=true

Run all tests
hybris.junit4.annotations.included=
hybris.junit4.annotations.excluded=
hybris.junit4.annotations.defaultIncluded=true

  • Constructor Details

    • DefaultAnnotationFilter

      public DefaultAnnotationFilter(org.junit.runner.manipulation.Filter existingFilter)
    • DefaultAnnotationFilter

      public DefaultAnnotationFilter(String includedList, String excludedList, boolean defaultAllowed)
  • Method Details

    • getExcludedAnnotations

      public Collection<Class> getExcludedAnnotations()
    • getIncludedAnnotations

      public Collection<Class> getIncludedAnnotations()
    • shouldRun

      public boolean shouldRun(org.junit.runner.Description description)
      Specified by:
      shouldRun in class org.junit.runner.manipulation.Filter
    • describe

      public String describe()
      Specified by:
      describe in class org.junit.runner.manipulation.Filter