Class TestListResolver

  • All Implemented Interfaces:
    GenericTestPattern<ResolvedTest,​java.lang.String,​java.lang.String>, TestFilter<java.lang.String,​java.lang.String>

    public class TestListResolver
    extends java.lang.Object
    implements GenericTestPattern<ResolvedTest,​java.lang.String,​java.lang.String>
    Resolved multi pattern filter e.g. -Dtest=MyTest#test,!AnotherTest#otherTest into an object model composed of included and excluded tests.
    The methods shouldRun(String, String) are filters easily used in JUnit filter or TestNG. This class is independent of JUnit and TestNG API.
    It is accessed by Java Reflection API in SurefireReflector using specific ClassLoader.
    • Field Detail

      • JAVA_CLASS_FILE_EXTENSION

        private static final java.lang.String JAVA_CLASS_FILE_EXTENSION
        See Also:
        Constant Field Values
      • includedPatterns

        private final java.util.Set<ResolvedTest> includedPatterns
      • excludedPatterns

        private final java.util.Set<ResolvedTest> excludedPatterns
      • hasIncludedMethodPatterns

        private final boolean hasIncludedMethodPatterns
      • hasExcludedMethodPatterns

        private final boolean hasExcludedMethodPatterns
    • Constructor Detail

      • TestListResolver

        public TestListResolver​(java.util.Collection<java.lang.String> tests)
      • TestListResolver

        public TestListResolver​(java.lang.String csvTests)
      • TestListResolver

        public TestListResolver​(java.util.Collection<java.lang.String> included,
                                java.util.Collection<java.lang.String> excluded)
      • TestListResolver

        private TestListResolver​(boolean hasIncludedMethodPatterns,
                                 boolean hasExcludedMethodPatterns,
                                 java.util.Set<ResolvedTest> includedPatterns,
                                 java.util.Set<ResolvedTest> excludedPatterns)
        Used only in method filter.
    • Method Detail

      • getEmptyTestListResolver

        public static TestListResolver getEmptyTestListResolver()
      • isWildcard

        public final boolean isWildcard()
      • shouldRun

        public boolean shouldRun​(java.lang.Class<?> testClass,
                                 java.lang.String methodName)
      • shouldRun

        public boolean shouldRun​(java.lang.String testClassFile,
                                 java.lang.String methodName)
        Returns true if satisfies testClassFile and methodName filter.
        Specified by:
        shouldRun in interface TestFilter<java.lang.String,​java.lang.String>
        Parameters:
        testClassFile - format must be e.g. "my/package/MyTest.class" including class extension; or null
        methodName - real test-method name; or null
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toClassFileName

        public static java.lang.String toClassFileName​(java.lang.Class<?> test)
      • toClassFileName

        public static java.lang.String toClassFileName​(java.lang.String fullyQualifiedTestClass)
      • removeExclamationMark

        static java.lang.String removeExclamationMark​(java.lang.String s)
      • aggregatedTest

        private static java.lang.String aggregatedTest​(java.lang.String testPrefix,
                                                       java.util.Set<ResolvedTest> tests)
      • mergeIncludedAndExcludedTests

        private static java.util.Collection<java.lang.String> mergeIncludedAndExcludedTests​(java.util.Collection<java.lang.String> included,
                                                                                            java.util.Collection<java.lang.String> excluded)
      • isRegexPrefixedPattern

        static boolean isRegexPrefixedPattern​(java.lang.String pattern)
      • isRegexMinLength

        static boolean isRegexMinLength​(java.lang.String pattern)
      • unwrapRegex

        static java.lang.String[] unwrapRegex​(java.lang.String regex)
      • unwrap

        static java.lang.String[] unwrap​(java.lang.String request)
      • nonRegexClassAndMethods

        static void nonRegexClassAndMethods​(java.lang.String clazz,
                                            java.lang.String methods,
                                            boolean isExcluded,
                                            IncludedExcludedPatterns patterns,
                                            java.util.Collection<ResolvedTest> includedFilters,
                                            java.util.Collection<ResolvedTest> excludedFilters)
      • resolveTestRequest

        static void resolveTestRequest​(java.lang.String request,
                                       IncludedExcludedPatterns patterns,
                                       java.util.Collection<ResolvedTest> includedFilters,
                                       java.util.Collection<ResolvedTest> excludedFilters)
        Requires trimmed request been not equal to "!".
      • haveMethodPatterns

        private static boolean haveMethodPatterns​(java.util.Set<ResolvedTest> patterns)