• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ArgumentsSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.junit.jupiter.params.provider.ArgumentsSource的典型用法代码示例。如果您正苦于以下问题:Java ArgumentsSource类的具体用法?Java ArgumentsSource怎么用?Java ArgumentsSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArgumentsSource类属于org.junit.jupiter.params.provider包,在下文中一共展示了ArgumentsSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: provideTestTemplateInvocationContexts

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
    Method templateMethod = Preconditions.notNull(context.getTestMethod().orElse(null),
            "test method must not be null");
    AutoTestNameFormatter formatter = createNameFormatter(templateMethod);
    AtomicLong invocationCount = new AtomicLong(0L);
    return (Stream) findRepeatableAnnotations(templateMethod, ArgumentsSource.class)
            .stream()
            .map(ArgumentsSource::value)
            .map(ReflectionUtils::newInstance)
            .map(provider -> AnnotationConsumerInitializer.initialize(templateMethod, provider))
            .flatMap(provider -> arguments(provider, context))
            .map(Arguments::get)
            .map((arguments) -> {
                return new AutoTestInvocationContext(formatter, arguments);
            })
            .peek((invocationContext) -> {
                invocationCount.incrementAndGet();
            }).onClose(() -> {
                Preconditions.condition(invocationCount.get() > 0L, () -> {
                    return "当使用注解 @" + AutoTest.class.getSimpleName() + " 的时候,测试方法需要至少一个参数";
                });
            });

}
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:26,代码来源:AutoTestExtension.java


示例2: testValidArgumentsSucceed

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns successfully with valid arguments")
@ArgumentsSource(ValidArgumentsProvider.class)
void testValidArgumentsSucceed(Sleep sleep,
                               Duration initialDelay,
                               Duration defaultTimeout,
                               PatientExecutionHandler executionHandler,
                               DelaySupplierFactory delaySupplierFactory,
                               PatientExecutable<Boolean> executable,
                               Predicate<Boolean> filter,
                               Supplier<String> messageSupplier) {
    try {
        Assertions.assertNotNull(getInstance(sleep,
                                             initialDelay,
                                             defaultTimeout,
                                             executionHandler,
                                             delaySupplierFactory,
                                             executable,
                                             filter,
                                             messageSupplier),
                                 "Should have returned a non-null instance for valid arguments.");
    } catch (Throwable thrown) {
        Assertions.fail("Expected to construct a PatientWaitFuture with valid arguments but throwable was caught: " + thrown);
    }
}
 
开发者ID:redfin,项目名称:patience,代码行数:26,代码来源:PatientWaitFutureTest.java


示例3: testSucceedsWithNullMessage

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns successfully with valid arguments and a null message")
@ArgumentsSource(ValidArgumentsProvider.class)
void testSucceedsWithNullMessage(Sleep sleep,
                                 Duration initialDelay,
                                 Duration defaultTimeout,
                                 PatientExecutionHandler executionHandler,
                                 DelaySupplierFactory delaySupplierFactory,
                                 PatientExecutable<Boolean> executable,
                                 Predicate<Boolean> filter) {
    try {
        Assertions.assertNotNull(getInstance(sleep,
                                             initialDelay,
                                             defaultTimeout,
                                             executionHandler,
                                             delaySupplierFactory,
                                             executable,
                                             filter,
                                             (String) null),
                                 "Should have returned a non-null instance for valid arguments.");
    } catch (Throwable thrown) {
        Assertions.fail("Expected to construct a PatientWaitFuture with valid arguments but throwable was caught: " + thrown);
    }
}
 
开发者ID:redfin,项目名称:patience,代码行数:25,代码来源:PatientWaitFutureTest.java


示例4: testInvalidArgumentsThrowsException

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it throws an exception for invalid arguments")
@ArgumentsSource(InvalidArgumentsProvider.class)
void testInvalidArgumentsThrowsException(Sleep sleep,
                                         Duration initialDelay,
                                         Duration defaultTimeout,
                                         PatientExecutionHandler executionHandler,
                                         DelaySupplierFactory delaySupplierFactory,
                                         PatientExecutable<Boolean> executable,
                                         Predicate<Boolean> filter,
                                         Supplier<String> messageSupplier) {
    Assertions.assertThrows(IllegalArgumentException.class,
                            () -> getInstance(sleep,
                                              initialDelay,
                                              defaultTimeout,
                                              executionHandler,
                                              delaySupplierFactory,
                                              executable,
                                              filter,
                                              messageSupplier),
                            "Should have thrown an exception for an invalid argument");
}
 
开发者ID:redfin,项目名称:patience,代码行数:23,代码来源:PatientWaitFutureTest.java


示例5: testValidArgumentsSucceed

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns successfully with valid arguments")
@ArgumentsSource(PatientRetryFutureTest.ValidArgumentsProvider.class)
void testValidArgumentsSucceed(Sleep sleep,
                               Duration initialDelay,
                               int defaultNumberOfRetries,
                               PatientExecutionHandler executionHandler,
                               DelaySupplierFactory delaySupplierFactory,
                               PatientExecutable<Boolean> executable,
                               Predicate<Boolean> filter,
                               Supplier<String> messageSupplier) {
    try {
        Assertions.assertNotNull(getInstance(sleep,
                                             initialDelay,
                                             defaultNumberOfRetries,
                                             executionHandler,
                                             delaySupplierFactory,
                                             executable,
                                             filter,
                                             messageSupplier),
                                 "Should have returned a non-null instance for valid arguments.");
    } catch (Throwable thrown) {
        Assertions.fail("Expected to construct a PatientRetryFuture with valid arguments but throwable was caught: " + thrown);
    }
}
 
开发者ID:redfin,项目名称:patience,代码行数:26,代码来源:PatientRetryFutureTest.java


示例6: testSucceedsWithNullMessage

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns successfully with valid arguments and a null message")
@ArgumentsSource(PatientRetryFutureTest.ValidArgumentsProvider.class)
void testSucceedsWithNullMessage(Sleep sleep,
                                 Duration initialDelay,
                                 int defaultNumberOfRetries,
                                 PatientExecutionHandler executionHandler,
                                 DelaySupplierFactory delaySupplierFactory,
                                 PatientExecutable<Boolean> executable,
                                 Predicate<Boolean> filter) {
    try {
        Assertions.assertNotNull(getInstance(sleep,
                                             initialDelay,
                                             defaultNumberOfRetries,
                                             executionHandler,
                                             delaySupplierFactory,
                                             executable,
                                             filter,
                                             (String) null),
                                 "Should have returned a non-null instance for valid arguments.");
    } catch (Throwable thrown) {
        Assertions.fail("Expected to construct a PatientRetryFuture with valid arguments but throwable was caught: " + thrown);
    }
}
 
开发者ID:redfin,项目名称:patience,代码行数:25,代码来源:PatientRetryFutureTest.java


示例7: testInvalidArgumentsThrowsException

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it throws an exception for invalid arguments")
@ArgumentsSource(PatientRetryFutureTest.InvalidArgumentsProvider.class)
void testInvalidArgumentsThrowsException(Sleep sleep,
                                         Duration initialDelay,
                                         int defaultNumberOfRetries,
                                         PatientExecutionHandler executionHandler,
                                         DelaySupplierFactory delaySupplierFactory,
                                         PatientExecutable<Boolean> executable,
                                         Predicate<Boolean> filter,
                                         Supplier<String> messageSupplier) {
    Assertions.assertThrows(IllegalArgumentException.class,
                            () -> getInstance(sleep,
                                              initialDelay,
                                              defaultNumberOfRetries,
                                              executionHandler,
                                              delaySupplierFactory,
                                              executable,
                                              filter,
                                              messageSupplier),
                            "Should have thrown an exception for an invalid argument");
}
 
开发者ID:redfin,项目名称:patience,代码行数:23,代码来源:PatientRetryFutureTest.java


示例8: testWithArgumentsSource

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@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);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:11,代码来源:ArgumentSourcesParameterizedTest.java


示例9: testWithArgumentsSource

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(CustomArgumentsProvider1.class)
void testWithArgumentsSource(String first, int second) {
    System.out.println("Parameterized test with (String) " + first
            + " and (int) " + second);

    assertNotNull(first);
    assertTrue(second > 0);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:10,代码来源:ArgumentSourceParameterizedTest.java


示例10: testDeserialization

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(SerializedMessageRequestsProvider.class)
void testDeserialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            MessageRequest.class,
            MessageRequestTests::assertValid);
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:MessageRequestTests.java


示例11: testDeserialization

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(SerializedAttachmentsProvider.class)
void testDeserialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Attachment.class,
            AttachmentTests::assertValid);
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:AttachmentTests.java


示例12: testSerialization

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(SerializedColorsProvider.class)
void testSerialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Color.class,
            ColorTests::assertValid);
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:ColorTests.java


示例13: testDeserialization

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(SerializedFootersProvider.class)
void testDeserialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Footer.class,
            FooterTests::assertValid);
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:FooterTests.java


示例14: testSerialization

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(SerializedAuthorsProvider.class)
void testSerialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Author.class,
            AuthorTests::assertValid);
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:AuthorTests.java


示例15: testSerialization

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(SerializedFieldsProvider.class)
void testSerialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Field.class,
            FieldTests::assertValid);
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:FieldTests.java


示例16: testDeserialization

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(SerializedTitlesProvider.class)
void testDeserialization(JsonNode json) {
    MoreAssertions.assertSerializable(json,
            Title.class,
            TitleTests::assertValid);
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:TitleTests.java


示例17: testSendMessage

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@ArgumentsSource(MessageRequestProvider.class)
void testSendMessage(MessageRequest messageRequest, TestInfo testInfo) {
    assertThat(SlackWebHookService.with(assumingEnvironmentWebHookToken())
                    .sendMessage(EnrichTestMessageRequest.get().apply(messageRequest, testInfo)),
            is(equalTo(ResponseCode.OK)));
}
 
开发者ID:palantir,项目名称:roboslack,代码行数:8,代码来源:SlackWebHookServiceTests.java


示例18: testCanInstantiateWithValidArguments

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns a non-null instance successfully for valid arguments")
@ArgumentsSource(ValidArgumentsProvider.class)
void testCanInstantiateWithValidArguments(Sleep sleep,
                                          Duration initialDelay,
                                          Duration defaultTimeout,
                                          PatientExecutionHandler handler,
                                          DelaySupplierFactory delaySupplierFactory) {
    try {
        Assertions.assertNotNull(getInstance(sleep, initialDelay, defaultTimeout, handler, delaySupplierFactory),
                                 "Should have received a non-null instance with valid arguments.");
    } catch (Throwable thrown) {
        Assertions.fail("Should have been able to construct a PatientWait with valid arguments but caught throwable: " + thrown);
    }
}
 
开发者ID:redfin,项目名称:patience,代码行数:16,代码来源:PatientWaitTest.java


示例19: testThrowsExceptionWithInvalidArguments

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it throws an exception for invalid arguments")
@ArgumentsSource(InvalidArgumentsProvider.class)
void testThrowsExceptionWithInvalidArguments(Sleep sleep,
                                             Duration initialDelay,
                                             Duration defaultTimeout,
                                             PatientExecutionHandler handler,
                                             DelaySupplierFactory delaySupplierFactory) {
    Assertions.assertThrows(IllegalArgumentException.class,
                            () -> getInstance(sleep, initialDelay, defaultTimeout, handler, delaySupplierFactory),
                            "Should have thrown an exception when the constructor is called with an invalid argument.");
}
 
开发者ID:redfin,项目名称:patience,代码行数:13,代码来源:PatientWaitTest.java


示例20: testCanInstantiateWithValidArguments

import org.junit.jupiter.params.provider.ArgumentsSource; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns a non-null instance successfully for valid arguments")
@ArgumentsSource(ValidArgumentsProvider.class)
void testCanInstantiateWithValidArguments(Sleep sleep,
                                          Duration initialDelay,
                                          int defaultNumberOfRetries,
                                          PatientExecutionHandler handler,
                                          DelaySupplierFactory delaySupplierFactory) {
    try {
        Assertions.assertNotNull(getInstance(sleep, initialDelay, defaultNumberOfRetries, handler, delaySupplierFactory),
                                 "Should have received a non-null instance with valid arguments.");
    } catch (Throwable thrown) {
        Assertions.fail("Should have been able to construct a PatientRetry with valid arguments but caught throwable: " + thrown);
    }
}
 
开发者ID:redfin,项目名称:patience,代码行数:16,代码来源:PatientRetryTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SliderPage类代码示例发布时间:2022-05-23
下一篇:
Java JAXBHeader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap