Class 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

    • Field Summary

      • Fields inherited from class org.junit.runner.manipulation.Filter

        ALL
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultAnnotationFilter​(java.lang.String includedList, java.lang.String excludedList, boolean defaultAllowed)  
      DefaultAnnotationFilter​(org.junit.runner.manipulation.Filter existingFilter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String describe()  
      java.util.Collection<java.lang.Class> getExcludedAnnotations()  
      java.util.Collection<java.lang.Class> getIncludedAnnotations()  
      boolean shouldRun​(org.junit.runner.Description description)  
      • Methods inherited from class org.junit.runner.manipulation.Filter

        apply, intersect, matchMethodDescription
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultAnnotationFilter

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

        public DefaultAnnotationFilter​(java.lang.String includedList,
                                       java.lang.String excludedList,
                                       boolean defaultAllowed)
    • Method Detail

      • getExcludedAnnotations

        public java.util.Collection<java.lang.Class> getExcludedAnnotations()
      • getIncludedAnnotations

        public java.util.Collection<java.lang.Class> getIncludedAnnotations()
      • shouldRun

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

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