How to use getNormalTestClasses method of net.serenitybdd.junit.finder.TestFinder class

Best Serenity JUnit code snippet using net.serenitybdd.junit.finder.TestFinder.getNormalTestClasses

Source:TestFinder.java Github

copy

Full Screen

...9import java.util.*;10/**11 * The TestFinder class lets you find the Thucydides tests or test methods underneath a given package.12 * <p>You instantiate a TestFinder by providing the top-level package where the tests live.</p>13 * <p>You can then find the list of Thucydides test classes using getNormalTestClasses(), getDataDrivenTestClasses(),14 * and getAllTestClasses() (which returns both normal and data-driven tests).</p>15 * <p>You may also need to retrieve the list of test methods for a particular category of class. You can do this using the16 * getTestMethodsFrom() method, e.g.17 * <pre>new TestFinder("my.package").getTestMethodsFrom().normalTestClasses()</pre>18 */19public abstract class TestFinder {20 protected final String rootPackage;21 /**22 * Create a new test finder instance that will look for tests in the packages underneath the given root package.23 * @param rootPackage The root package used as the starting point when looking for test classes.24 */25 protected TestFinder(final String rootPackage) {26 this.rootPackage = rootPackage;27 }28 public static TestFinderBuilderFactory thatFinds() {29 return new TestFinderBuilderFactory();30 }31 public abstract List<Class<?>> getClasses();32 public abstract int countTestMethods();33 public TestMethodFinder findTestMethods() {34 return new TestMethodFinder(this);35 }36 protected List<Class<?>> getAllTestClasses() {37 return ClassFinder.loadClasses().annotatedWith(RunWith.class).fromPackage(rootPackage);38 }39 protected Set<Class<?>> getNormalTestClasses() {40 Set<Class<?>> normalTestClasses = new HashSet();41 for(Class<?> testClass : getAllTestClasses()) {42 if (normalThucydidesTest(testClass)) {43 normalTestClasses.add(testClass);44 }45 }46 return normalTestClasses;47 }48 protected List<Class<?>> getDataDrivenTestClasses() {49 return ClassFinder.loadClasses().annotatedWith(UseTestDataFrom.class).fromPackage(rootPackage);50 }51 protected List<Class<?>> sorted(List<Class<?>> classes) {52 Collections.sort(classes, byClassName());53 return classes;...

Full Screen

Full Screen

Source:NormalTestFinder.java Github

copy

Full Screen

...10 super(rootPackage);11 }12 @Override13 public List<Class<?>> getClasses() {14 return sorted(new ArrayList(getNormalTestClasses()));15 }16 @Override17 public int countTestMethods() {18 return getAllTestMethods().size();19 }20}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Serenity JUnit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful