Java 类org.junit.jupiter.params.ParameterizedTest 实例源码

项目:micrometer    文件:StatsdMeterRegistryTest.java   
@ParameterizedTest
@EnumSource(StatsdFlavor.class)
void timerLineProtocol(StatsdFlavor flavor) {
    String line = null;
    switch (flavor) {
        case Etsy:
            line = "myTimer.myTag.val:1|ms";
            break;
        case Datadog:
            line = "my.timer:1|ms|#my.tag:val";
            break;
        case Telegraf:
            line = "my_timer,my_tag=val:1|ms";
    }

    assertLines(r -> r.timer("my.timer", "my.tag", "val").record(1, TimeUnit.MILLISECONDS),
        flavor, line);
}
项目:qpp-conversion-tool    文件:CpcPlusAcceptanceTest.java   
@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();
}
项目:roboslack    文件:ColorTests.java   
@ParameterizedTest
@EnumSource(Color.Preset.class)
void testPresetStrings(Color.Preset preset) {
    Color color = Color.of(preset.toString());
    assertValid(color);
    assertTrue(color.isPreset());
    assertThat(color.asPreset(), is(equalTo(preset)));
}
项目:mastering-junit5    文件:ValueSourceStringsParameterizedTest.java   
@ParameterizedTest
@ValueSource(strings = { "Hello", "World" })
void testWithStrings(String argument) {
    System.out.println(
            "Parameterized test with (String) parameter: " + argument);
    assertNotNull(argument);
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:ValueSourcePrimitiveTypesParameterizedTest.java   
@ParameterizedTest
@ValueSource(longs = { 2L, 3L })
void testWithLongs(long argument) {
    System.out.println(
            "Parameterized test with (long) argument: " + argument);
    assertNotNull(argument);
}
项目:mastering-junit5    文件:EnumSourceFilteringParameterizedTest.java   
@ParameterizedTest
@EnumSource(value = TimeUnit.class, mode = EXCLUDE, names = { "DAYS",
        "HOURS" })
void testWithExcludeEnum(TimeUnit argument) {
    System.out.println(
            "Parameterized test with excluded (TimeUnit) argument: "
                    + argument);
    assertNotNull(argument);
}
项目:ocraft-s2client    文件:ActionSpatialUnitSelectionPointTest.java   
@ParameterizedTest(name = "\"{0}\" is serialization of {1}")
@MethodSource(value = "unitSelectionPointTypeMappings")
void serializesToSc2ApiUnitSelectionPointType(
        Spatial.ActionSpatialUnitSelectionPoint.Type expectedSc2ApiSelectionPointType,
        ActionSpatialUnitSelectionPoint.Type selectionPointType) {
    assertThat(selectionPointType.toSc2Api()).isEqualTo(expectedSc2ApiSelectionPointType);
}
项目:ocraft-s2client    文件:ActionUiControlGroupTest.java   
@ParameterizedTest(name = "\"{0}\" is serialization of {1}")
@MethodSource(value = "controlGroupActionMappings")
void serializesToSc2ApiControlGroupAction(
        Ui.ActionControlGroup.ControlGroupAction expectedSc2ApiControlGroupAction,
        ActionUiControlGroup.Action controlGroupAction) {
    assertThat(controlGroupAction.toSc2Api()).isEqualTo(expectedSc2ApiControlGroupAction);
}
项目:mastering-junit5    文件:ArgumentSourcesParameterizedTest.java   
@ParameterizedTest
@ArgumentsSources({ @ArgumentsSource(CustomArgumentsProvider1.class),
        @ArgumentsSource(CustomArgumentsProvider2.class) })
void testWithArgumentsSource(String first, int second) {
    System.out.println("Parameterized test with (String) " + first
            + " and (int) " + second);

    assertNotNull(first);
    assertTrue(second > 0);
}
项目:mastering-junit5    文件:MethodSourcePrimitiveTypesParameterizedTest.java   
@ParameterizedTest
@MethodSource("longProvider")
void testWithLongProvider(long argument) {
    System.out.println(
            "Parameterized test with (long) argument: " + argument);
    assertNotNull(argument);
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:MethodSourceStringsParameterizedTest.java   
@ParameterizedTest
@MethodSource("stringProvider")
void testWithStringProvider(String argument) {
    System.out.println(
            "Parameterized test with (String) argument: " + argument);
    assertNotNull(argument);
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:ValueSourcePrimitiveTypesParameterizedTest.java   
@ParameterizedTest
@ValueSource(doubles = { 4d, 5d })
void testWithDoubles(double argument) {
    System.out.println(
            "Parameterized test with (double) argument: " + argument);
    assertNotNull(argument);
}
项目:mastering-junit5    文件:ImplicitConversionParameterizedTest.java   
@ParameterizedTest
@ValueSource(strings = "SECONDS")
void testWithImplicitConversionToEnum(TimeUnit argument) {
    System.out.println("Argument " + argument + " is a type of "
            + argument.getDeclaringClass());
    assertNotNull(argument.name());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:EnumSourceFilteringParameterizedTest.java   
@ParameterizedTest
@EnumSource(value = TimeUnit.class, mode = MATCH_ALL, names = "^(M|N).+SECONDS$")
void testWithRegexEnum(TimeUnit argument) {
    System.out.println(
            "Parameterized test with regex filtered (TimeUnit) argument: "
                    + argument);
    assertNotNull(argument);
}
项目:mastering-junit5    文件:CustomNamesParameterizedTest.java   
@DisplayName("Display name of test container")
@ParameterizedTest(name = "[{index}] first argument=\"{0}\", second argument={1}")
@CsvSource({ "mastering, 1", "parameterized, 2", "tests, 3" })
void testWithCustomDisplayNames(String first, int second) {
    System.out.println(
            "Testing with parameters: " + first + " and " + second);
}
项目:mastering-junit5    文件:MethodSourceMixedTypesParameterizedTest.java   
@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);
}
项目:mastering-junit5    文件:EnumSourceParameterizedTest.java   
@ParameterizedTest
@EnumSource(TimeUnit.class)
void testWithEnum(TimeUnit argument) {
    System.out.println(
            "Parameterized test with (TimeUnit) argument: " + argument);
    assertNotNull(argument);
}
项目:ocraft-s2client    文件:ResponseReplayInfoTest.java   
@ParameterizedTest(name = "\"{0}\" is mapped to {1}")
@MethodSource(value = "responseReplayInfoErrorMappings")
void mapsSc2ApiResponseGameError(
        Sc2Api.ResponseReplayInfo.Error sc2ApiResponseReplayInfoError,
        ResponseReplayInfo.Error expectedResponseReplayInfoError) {
    assertThat(ResponseReplayInfo.Error.from(sc2ApiResponseReplayInfoError))
            .isEqualTo(expectedResponseReplayInfoError);
}
项目:fuse-nio-adapter    文件:OpenOptionsUtilTest.java   
@ParameterizedTest
@MethodSource("openOptionsProvider")
public void testOpenFlagsMaskToSet(Set<OpenOption> expectedOptions, Set<OpenFlags> flags) {
    BitMaskEnumUtil enumUtil = Mockito.mock(BitMaskEnumUtil.class);
    Mockito.verifyNoMoreInteractions(enumUtil);
    OpenOptionsUtil util = new OpenOptionsUtil(enumUtil);
    Set<OpenOption> options = util.fuseOpenFlagsToNioOpenOptions(flags);
    Assertions.assertEquals(expectedOptions, options);
}
项目:fuse-nio-adapter    文件:FileAttributesUtilTest.java   
@ParameterizedTest
@MethodSource("accessModeProvider")
public void testAccessModeMaskToSet(Set<AccessMode> expectedModes, int mask) {
    FileAttributesUtil util = new FileAttributesUtil();
    Set<AccessMode> accessModes = util.accessModeMaskToSet(mask);
    Assertions.assertEquals(expectedModes, accessModes);
}
项目:fuse-nio-adapter    文件:FileAttributesUtilTest.java   
@ParameterizedTest
@MethodSource("filePermissionProvider")
public void testOctalModeToPosixPermissions(Set<PosixFilePermission> expectedPerms, long octalMode) {
    FileAttributesUtil util = new FileAttributesUtil();
    Set<PosixFilePermission> perms = util.octalModeToPosixPermissions(octalMode);
    Assertions.assertEquals(expectedPerms, perms);
}
项目:AdvancedDataProfilingSeminar    文件:NullHandlingTest.java   
@ParameterizedTest
@EnumSource(QueryType.class)
void allQueriesShouldHandleNullValueForUnary(final QueryType queryType) {
  final DatabaseValidation validation = new DatabaseValidation(context, queries.get(queryType));

  final ValidationResult result = validation.validate(getValidUnaryWithNulls());

  assertThat(result.isValid()).isTrue();
}
项目:selenium-jupiter    文件:ForcedAnnotationReaderTest.java   
@ParameterizedTest
@MethodSource("forcedTestProvider")
void forcedTest(Class<? extends DriverHandler> handler, Class<?> testClass,
        Class<?> driverClass, String testName) throws Exception {
    Parameter parameter = testClass.getMethod(testName, driverClass)
            .getParameters()[0];
    assertThrows(SeleniumJupiterException.class, () -> {
        handler.getDeclaredConstructor(Parameter.class,
                ExtensionContext.class).newInstance(parameter, null)
                .resolve();
    });
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:MethodSourcePrimitiveTypesParameterizedTest.java   
@ParameterizedTest
@MethodSource("intProvider")
void testWithIntProvider(int argument) {
    System.out
            .println("Parameterized test with (int) argument: " + argument);
    assertNotNull(argument);
}
项目:roboslack    文件:AttachmentTests.java   
@ParameterizedTest
@ArgumentsSource(SerializedAttachmentsProvider.class)
void testDeserialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Attachment.class,
            AttachmentTests::assertValid);
}
项目:filter-sort-jooq-api    文件:FilterMultipleValueParserIdentityTest.java   
@ParameterizedTest
@MethodSource("goodStringParsableAndResult")
void parse(final String argument, final List<String> expected) {
    Assertions.assertEquals(expected, FilterMultipleValueParser.ofIdentity().parse(argument));
    Assertions.assertEquals(expected.size(), FilterMultipleValueParser.ofIdentity().parse(argument).size());
    Assertions.assertEquals(expected, FilterMultipleValueParser.ofIdentity().parse(argument, ","));
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:MethodSourceMixedTypesParameterizedTest.java   
@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);
}
项目:roboslack    文件:FooterTests.java   
@ParameterizedTest
@ArgumentsSource(SerializedFootersProvider.class)
void testDeserialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Footer.class,
            FooterTests::assertValid);
}
项目:filter-sort-jooq-api    文件:ValueTest.java   
@ParameterizedTest
@MethodSource("valuesStream")
void getValue(final Value value) {
    for (int i = 0; i < value.size(); i++) {
        Assertions.assertNotNull(value.getValue(i));
    }
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:ArgumentSourcesParameterizedTest.java   
@ParameterizedTest
@ArgumentsSources({ @ArgumentsSource(CustomArgumentsProvider1.class),
        @ArgumentsSource(CustomArgumentsProvider2.class) })
void testWithArgumentsSource(String first, int second) {
    System.out.println("Parameterized test with (String) " + first
            + " and (int) " + second);

    assertNotNull(first);
    assertTrue(second > 0);
}
项目:micrometer    文件:TimeWindowRotationTest.java   
@ParameterizedTest
@MethodSource("histogramTypes")
void expectedValueRangeValidation(Class<? extends TimeWindowHistogramBase<?, ?>> histogramType) throws Exception {
    expectValidationFailure(histogramType, HistogramConfig.builder()
                                                          .minimumExpectedValue(0L)
                                                          .build());
    expectValidationFailure(histogramType, HistogramConfig.builder()
                                                          .minimumExpectedValue(10L)
                                                          .maximumExpectedValue(9L)
                                                          .build());
}
项目:roboslack    文件:SlackWebHookServiceTests.java   
@ParameterizedTest
@ArgumentsSource(MessageRequestProvider.class)
void testSendMessage(MessageRequest messageRequest, TestInfo testInfo) {
    assertThat(SlackWebHookService.with(assumingEnvironmentWebHookToken())
                    .sendMessage(EnrichTestMessageRequest.get().apply(messageRequest, testInfo)),
            is(equalTo(ResponseCode.OK)));
}
项目:micrometer    文件:TimeWindowRotationTest.java   
@ParameterizedTest
@MethodSource("histogramTypes")
void bufferLengthValidation(Class<? extends TimeWindowHistogramBase<?, ?>> histogramType) throws Exception {
    expectValidationFailure(histogramType, HistogramConfig.builder()
                                                          .histogramBufferLength(-1)
                                                          .build());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:ImplicitConversionParameterizedTest.java   
@ParameterizedTest
@ValueSource(strings = "2017-07-25")
void testWithImplicitConversionToLocalDate(LocalDate argument) {
    System.out.println("Argument " + argument + " is a type of "
            + argument.getClass());
    assertNotNull(argument);
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:ValueSourcePrimitiveTypesParameterizedTest.java   
@ParameterizedTest
@ValueSource(ints = { 0, 1 })
void testWithInts(int argument) {
    System.out
            .println("Parameterized test with (int) argument: " + argument);
    assertNotNull(argument);
}
项目:roboslack    文件:FieldTests.java   
@ParameterizedTest
@ArgumentsSource(SerializedFieldsProvider.class)
void testSerialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Field.class,
            FieldTests::assertValid);
}
项目:micrometer    文件:StatsdMeterRegistryTest.java   
@ParameterizedTest
@EnumSource(StatsdFlavor.class)
void longTaskTimerLineProtocol(StatsdFlavor flavor) {
    final Function<MeterRegistry, LongTaskTimer> ltt = r -> r.more().longTaskTimer("my.long.task", "my.tag", "val");

    StepVerifier
        .withVirtualTime(() -> {
            String[] lines = null;
            switch (flavor) {
                case Etsy:
                    lines = new String[]{
                        "myLongTask.myTag.val.statistic.activetasks:1|c",
                        "myLongTaskDuration.myTag.val.statistic.value:1|c",
                    };
                    break;
                case Datadog:
                    lines = new String[]{
                        "my.long.task:1|c|#statistic:activetasks,myTag:val",
                        "my.long.task:1|c|#statistic:duration,myTag:val",
                    };
                    break;
                case Telegraf:
                    lines = new String[]{
                        "myLongTask,statistic=activetasks,myTag=val:1|c",
                        "myLongTask,statistic=duration,myTag=val:1|c",
                    };
            }

            assertLines(r -> ltt.apply(r).start(), flavor, lines);
            return null;
        })
        .then(() -> mockClock.add(10, TimeUnit.MILLISECONDS))
        .thenAwait(Duration.ofMillis(10));
}
项目:ocraft-s2client    文件:ResponseCreateGameTest.java   
@ParameterizedTest(name = "\"{0}\" is mapped to {1}")
@MethodSource(value = "responseCreateGameErrorMappings")
void mapsSc2ApiResponseCreateGameError(
        Sc2Api.ResponseCreateGame.Error sc2ApiResponseCreateGameError,
        ResponseCreateGame.Error expectedResponseCreateGameError) {
    assertThat(ResponseCreateGame.Error.from(sc2ApiResponseCreateGameError))
            .isEqualTo(expectedResponseCreateGameError);
}
项目:roboslack    文件:ColorTests.java   
@ParameterizedTest
@ArgumentsSource(SerializedColorsProvider.class)
void testSerialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Color.class,
            ColorTests::assertValid);
}
项目:stf-console-client    文件:StfCommanderTest.java   
@DisplayName("Command without params should be called with an empty DeviceParams object")
@ParameterizedTest(name = "Command is {0}")
@EnumSource(DeviceParamsProducingCommand.class)
void commandsEmptyParamsNullableFields(DeviceParamsProducingCommand source) throws Exception {
    DevicesParams value = runDeviceParamsTest(source, "");
    assertNull(value.getAbi());
    assertNull(value.getNameFilterDescription());
    assertNull(value.getProviderFilterDescription());
    assertNull(value.getSerialFilterDescription());
    assertEquals(0, value.getApiVersion());
    assertEquals(0, value.getMaxApiVersion());
    assertEquals(0, value.getMinApiVersion());
    assertEquals(0, value.getCount());
    assertFalse(value.isAllDevices());
}