本文整理汇总了Java中org.junit.jupiter.params.provider.MethodSource类的典型用法代码示例。如果您正苦于以下问题:Java MethodSource类的具体用法?Java MethodSource怎么用?Java MethodSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MethodSource类属于org.junit.jupiter.params.provider包,在下文中一共展示了MethodSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFirefoxOptions
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("testClassProvider")
@SuppressWarnings("unchecked")
void testFirefoxOptions(Class<?> testClass) throws Exception {
Parameter parameter = testClass
.getMethod("webrtcTest", FirefoxDriver.class)
.getParameters()[0];
Optional<Object> testInstance = Optional.of(testClass.newInstance());
FirefoxOptions firefoxOptions = (FirefoxOptions) annotationsReader
.getOptions(parameter, testInstance);
Map<String, Map<String, Boolean>> options = (Map<String, Map<String, Boolean>>) firefoxOptions
.asMap().get(FIREFOX_OPTIONS);
assertTrue(options.get("prefs")
.get("media.navigator.permission.disabled"));
assertTrue(options.get("prefs").get("media.navigator.streams.fake"));
}
示例2: buildConditions
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("goodMapConditionAndResult")
void buildConditions(final Map<String, String> params, final List<FilterValue> filterValues, final Condition expectedCondition) {
filteringJooqImpl1.getFilterValues().addAll(filterValues);
final Condition condition = filteringJooqImpl1.buildConditions(params);
Assertions.assertEquals(expectedCondition, condition);
}
示例3: loadJdkClass
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest(name = "loading {0}")
@MethodSource(value = "classNames")
public void loadJdkClass(String className, TestReporter reporter) throws ClassNotFoundException {
TestClassLoader classLoader = new TestClassLoader();
try {
Class c = classLoader.loadClass(className);
reporter.publishEntry(className, "visible");
// the assertion is pretty useless, but if `c` would not be used,
// dead code elimination might remove it
assertThat(c.getName()).isEqualTo(className);
} catch (ClassNotFoundException ex) {
reporter.publishEntry(className, "not visible");
throw ex;
}
}
示例4: valueWithGetterNumbered
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("valuesStream")
void valueWithGetterNumbered(final Value value) {
final int size = value.size();
Assertions.assertNotNull(((Value1) value).value1());
if (size > 1)
Assertions.assertNotNull(((Value2) value).value2());
if (size > 2)
Assertions.assertNotNull(((Value3) value).value3());
if (size > 3)
Assertions.assertNotNull(((Value4) value).value4());
if (size > 4)
Assertions.assertNotNull(((Value5) value).value5());
if (size > 5)
Assertions.assertNotNull(((Value6) value).value6());
}
示例5: valueWithGetterNumberedThrowsOutOfRange
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("valuesStream")
void valueWithGetterNumberedThrowsOutOfRange(final Value value) {
final int size = value.size();
// No class cast exception as Value == ValueImpl (supposedly)
if (size <= 1)
Assertions.assertThrows(IndexOutOfBoundsException.class, ((Value2) value)::value2);
if (size <= 2)
Assertions.assertThrows(IndexOutOfBoundsException.class, ((Value3) value)::value3);
if (size <= 3)
Assertions.assertThrows(IndexOutOfBoundsException.class, ((Value4) value)::value4);
if (size <= 4)
Assertions.assertThrows(IndexOutOfBoundsException.class, ((Value5) value)::value5);
if (size <= 5)
Assertions.assertThrows(IndexOutOfBoundsException.class, ((Value6) value)::value6);
}
示例6: testCpcPlusFileSuccesses
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("successData")
void testCpcPlusFileSuccesses(Path entry) throws IOException {
AllErrors errors = null;
Converter converter = new Converter(new PathSource(entry));
try {
converter.transform();
} catch (TransformException failure) {
errors = failure.getDetails();
}
assertThat(errors).isNull();
}
示例7: testCpcPlusFileFailures
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("failureData")
void testCpcPlusFileFailures(Path entry) throws IOException {
String fileName = entry.getFileName().toString();
assertWithMessage("No associated entry in fixture.json for the file %s", fileName).that(fixtureValues).containsKey(fileName);
Converter converter = new Converter(new PathSource(entry));
TransformException expected = Assertions.assertThrows(TransformException.class, converter::transform);
//runnning conversions on individual files
List<Detail> details = expected.getDetails().getErrors().get(0).getDetails();
verifyOutcome(fileName, details);
}
示例8: testCoverage
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("paths")
void testCoverage(Path path) throws IOException {
JsonWrapper metaWrapper = new JsonWrapper(false);
helper = new JsonPathToXpathHelper(path, metaWrapper, false);
JsonWrapper wrapper = new JsonWrapper(metaWrapper, true);
JsonNode root = om.readTree(wrapper.toString());
JsonPathAggregator agg = new JsonPathAggregator(root);
agg.getJsonPaths().forEach((key, value) -> helper.executeAttributeTest(key, value));
}
示例9: testConstructor
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("metadataProvider")
void testConstructor(Metadata metadata) {
UnprocessedCpcFileData cpcFileData = new UnprocessedCpcFileData(metadata);
assertThat(cpcFileData.getFileId()).isEqualTo(metadata.getUuid());
assertThat(cpcFileData.getFilename()).isEqualTo(metadata.getFileName());
assertThat(cpcFileData.getApm()).isEqualTo(metadata.getApm());
assertThat(cpcFileData.getConversionDate()).isEqualTo(metadata.getCreatedDate().toString());
assertThat(cpcFileData.getValidationSuccess()).isEqualTo(metadata.getOverallStatus());
}
示例10: testWithPersonProvider
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("personProvider")
void testWithPersonProvider(Person argument) {
System.out.println(
"Parameterized test with (Person) argument: " + argument);
assertNotNull(argument);
}
示例11: testWithIntProvider
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("intProvider")
void testWithIntProvider(int argument) {
System.out
.println("Parameterized test with (int) argument: " + argument);
assertNotNull(argument);
}
示例12: testWithDoubleProvider
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("doubleProvider")
void testWithDoubleProvider(double argument) {
System.out.println(
"Parameterized test with (double) argument: " + argument);
assertNotNull(argument);
}
示例13: testWithLongProvider
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("longProvider")
void testWithLongProvider(long argument) {
System.out.println(
"Parameterized test with (long) argument: " + argument);
assertNotNull(argument);
}
示例14: printAllGenerated
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("inputSourceBlocks")
public void printAllGenerated(List<String> block) throws IOException {
List<JavaFileObject> sourceJavaFileObject = getResourceStrings("input", block);
AutoValueProcessor processor = new AutoValueProcessor();
Compilation compilation = javac().withProcessors(processor).compile(sourceJavaFileObject);
ImmutableList<JavaFileObject> javaFileObjects = ImmutableList.<JavaFileObject>builder()
.addAll(compilation.generatedSourceFiles())
.build();
String destination = "src/test/resources/expected";
Files.createDirectories(Paths.get(destination));
javaFileObjects.forEach(
generated -> {
try {
String fileName = destination + generated.getName().replace("SOURCE_OUTPUT/", "");
Path parent = Paths.get(fileName).getParent();
Files.createDirectories(parent);
try (PrintWriter printWriter = new PrintWriter(fileName)) {
printWriter.println(generated.getCharContent(true).toString());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
);
}
示例15: testWithMultiArgMethodSource
import org.junit.jupiter.params.provider.MethodSource; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("stringAndIntProvider")
void testWithMultiArgMethodSource(String first, int second) {
System.out.println("Parameterized test with two arguments: (String) "
+ first + " and (int) " + second);
assertNotNull(first);
assertNotEquals(0, second);
}