当前位置: 首页>>代码示例>>Java>>正文


Java MethodSource类代码示例

本文整理汇总了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"));
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:19,代码来源:FirefoxAnnotationReaderTest.java

示例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);
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:8,代码来源:FilteringJooqTest.java

示例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;
	}
}
 
开发者ID:CodeFX-org,项目名称:java-9-wtf,代码行数:17,代码来源:BootstrapLoaderTest.java

示例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());
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:22,代码来源:ValueTest.java

示例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);
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:22,代码来源:ValueTest.java

示例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();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:16,代码来源:CpcPlusAcceptanceTest.java

示例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);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:14,代码来源:CpcPlusAcceptanceTest.java

示例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));
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:12,代码来源:JsonPathToXpathCoverageTest.java

示例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());
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:13,代码来源:UnprocessedCpcFileDataTest.java

示例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);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:8,代码来源:MethodSourceObjectsParameterizedTest.java

示例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);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:8,代码来源:MethodSourcePrimitiveTypesParameterizedTest.java

示例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);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:8,代码来源:MethodSourcePrimitiveTypesParameterizedTest.java

示例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);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:8,代码来源:MethodSourcePrimitiveTypesParameterizedTest.java

示例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);
                }
            }
    );
}
 
开发者ID:sopak,项目名称:auto-value-step-builder,代码行数:33,代码来源:GeneratorTest.java

示例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);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:10,代码来源:MethodSourceMixedTypesParameterizedTest.java


注:本文中的org.junit.jupiter.params.provider.MethodSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。