Class TestFinder

java.lang.Object
net.serenitybdd.junit.finder.TestFinder
Direct Known Subclasses:
DataDrivenTestFinder, DefaultTestFinder, NormalTestFinder

public abstract class TestFinder
extends java.lang.Object
The TestFinder class lets you find the Thucydides tests or test methods underneath a given package.

You instantiate a TestFinder by providing the top-level package where the tests live.

You can then find the list of Thucydides test classes using getNormalTestClasses(), getDataDrivenTestClasses(), and getAllTestClasses() (which returns both normal and data-driven tests).

You may also need to retrieve the list of test methods for a particular category of class. You can do this using the getTestMethodsFrom() method, e.g.

new TestFinder("my.package").getTestMethodsFrom().normalTestClasses()
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.lang.String rootPackage  
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected TestFinder​(java.lang.String rootPackage)
    Create a new test finder instance that will look for tests in the packages underneath the given root package.
  • Method Summary

    Modifier and Type Method Description
    abstract int countTestMethods()  
    TestMethodFinder findTestMethods()  
    protected java.util.List<java.lang.Class<?>> getAllTestClasses()  
    java.util.List<java.lang.reflect.Method> getAllTestMethods()  
    abstract java.util.List<java.lang.Class<?>> getClasses()  
    protected java.util.List<java.lang.Class<?>> getDataDrivenTestClasses()  
    protected java.util.Set<java.lang.Class<?>> getNormalTestClasses()  
    protected java.util.List<java.lang.Class<?>> sorted​(java.util.List<java.lang.Class<?>> classes)  
    static TestFinderBuilderFactory thatFinds()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • rootPackage

      protected final java.lang.String rootPackage
  • Constructor Details

    • TestFinder

      protected TestFinder​(java.lang.String rootPackage)
      Create a new test finder instance that will look for tests in the packages underneath the given root package.
      Parameters:
      rootPackage - The root package used as the starting point when looking for test classes.
  • Method Details

    • thatFinds

      public static TestFinderBuilderFactory thatFinds()
    • getClasses

      public abstract java.util.List<java.lang.Class<?>> getClasses()
    • countTestMethods

      public abstract int countTestMethods()
    • findTestMethods

      public TestMethodFinder findTestMethods()
    • getAllTestClasses

      protected java.util.List<java.lang.Class<?>> getAllTestClasses()
    • getNormalTestClasses

      protected java.util.Set<java.lang.Class<?>> getNormalTestClasses()
    • getDataDrivenTestClasses

      protected java.util.List<java.lang.Class<?>> getDataDrivenTestClasses()
    • sorted

      protected java.util.List<java.lang.Class<?>> sorted​(java.util.List<java.lang.Class<?>> classes)
    • getAllTestMethods

      public java.util.List<java.lang.reflect.Method> getAllTestMethods()