All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.junit.finder.DataDrivenTestFinder Maven / Gradle / Ivy

There is a newer version: 4.2.9
Show newest version
package net.serenitybdd.junit.finder;

import com.google.common.collect.Lists;
import net.serenitybdd.junit.runners.DataDrivenAnnotations;
import org.junit.runners.model.TestClass;

import java.io.IOException;
import java.util.List;

/**
 * Returns all of the Thucydides classes under the specified package.
 */
public class DataDrivenTestFinder extends TestFinder {
    public DataDrivenTestFinder(final String rootPackage) {
        super(rootPackage);
    }

    @Override
    public List> getClasses() {
        return sorted(Lists.newArrayList(getDataDrivenTestClasses()));
    }

    @Override
    public int countTestMethods() {
        int totalTestMethods = 0;
        for(Class testClass : getDataDrivenTestClasses()) {
            try {
                totalTestMethods += DataDrivenAnnotations.forClass(new TestClass(testClass)).countDataEntries();
            } catch (IOException e) {
                throw new IllegalArgumentException("Failed to read test data for " + testClass);
            }
        }
        return totalTestMethods;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy