微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,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),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<?,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","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,};
                    break;
                case Telegraf:
                    lines = new String[]{
                        "myLongTask,statistic=activetasks,mytag=val:1|c","myLongTask,statistic=duration,};
            }

            assertLines(r -> ltt.apply(r).start(),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());
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。