net.thucydides.junit.runners.DataDrivenAnnotations Maven / Gradle / Ivy
The newest version!
package net.thucydides.junit.runners;
import ch.lambdaj.function.convert.Converter;
import com.google.common.base.Splitter;
import net.thucydides.core.csv.CSVTestDataSource;
import net.thucydides.core.csv.TestDataSource;
import net.thucydides.core.guice.Injectors;
import net.thucydides.core.model.DataTable;
import net.thucydides.core.steps.FilePathParser;
import net.thucydides.core.util.EnvironmentVariables;
import net.thucydides.junit.annotations.TestData;
import net.thucydides.junit.annotations.UseTestDataFrom;
import org.apache.commons.lang3.StringUtils;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.TestClass;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import static ch.lambdaj.Lambda.convert;
public class DataDrivenAnnotations {
private final EnvironmentVariables environmentVariables;
private final Pattern DATASOURCE_PATH_SEPARATORS = Pattern.compile("[;,]");
public static DataDrivenAnnotations forClass(final Class testClass) {
return new DataDrivenAnnotations(testClass);
}
public static DataDrivenAnnotations forClass(final TestClass testClass) {
return new DataDrivenAnnotations(testClass);
}
private final TestClass testClass;
DataDrivenAnnotations(final Class testClass) {
this(new TestClass(testClass));
}
DataDrivenAnnotations(final TestClass testClass) {
this(testClass, Injectors.getInjector().getProvider(EnvironmentVariables.class).get() );
}
DataDrivenAnnotations(final TestClass testClass, EnvironmentVariables environmentVariables) {
this.testClass = testClass;
this.environmentVariables = environmentVariables;
}
DataDrivenAnnotations usingEnvironmentVariables(EnvironmentVariables environmentVariables) {
return new DataDrivenAnnotations(this.testClass, environmentVariables);
}
public DataTable getParametersTableFromTestDataSource() throws Throwable {
TestDataSource testDataSource = new CSVTestDataSource(findTestDataSource(), findTestDataSeparator());
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy