本文整理汇总了Java中org.junit.jupiter.api.TestInfo类的典型用法代码示例。如果您正苦于以下问题:Java TestInfo类的具体用法?Java TestInfo怎么用?Java TestInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestInfo类属于org.junit.jupiter.api包,在下文中一共展示了TestInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@Override
public MessageRequest apply(MessageRequest messageRequest, TestInfo testInfo) {
checkArgument(testInfo.getTestClass().isPresent());
checkArgument(testInfo.getTestMethod().isPresent());
String methodName = testInfo.getTestMethod().get().getName();
String className = testInfo.getTestClass().get().getSimpleName();
String basicSummary = String.format("Called from %s within %s",
methodName,
className);
return MessageRequest.builder()
.from(messageRequest)
.addAttachments(Attachment.builder()
.fallback(basicSummary)
.text(basicSummary)
.build())
.build();
}
示例2: testOne
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@Test
@DisplayName("My test")
@Tag("my-tag")
void testOne(TestInfo testInfo) {
System.out.println(testInfo.getDisplayName());
System.out.println(testInfo.getTags());
System.out.println(testInfo.getTestClass());
System.out.println(testInfo.getTestMethod());
}
示例3: test1
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@Test
@DisplayName("My test")
@Tag("my-tag")
void test1(TestInfo testInfo) {
System.out.println(testInfo.getDisplayName());
System.out.println(testInfo.getTags());
System.out.println(testInfo.getTestClass());
System.out.println(testInfo.getTestMethod());
}
示例4: testSendMessage
import org.junit.jupiter.api.TestInfo; //导入依赖的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)));
}
示例5: junitAndSpringMethodInjectionCombined
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@Test
void junitAndSpringMethodInjectionCombined(@Autowired Cat kittyCat, TestInfo testInfo, ApplicationContext context,
TestReporter testReporter) {
assertNotNull(testInfo, "TestInfo should have been injected by JUnit");
assertNotNull(testReporter, "TestReporter should have been injected by JUnit");
assertNotNull(context, "ApplicationContext should have been injected by Spring");
assertNotNull(kittyCat, "Cat should have been @Autowired by Spring");
}
示例6: SpringJUnit5ConstructorInjectionTests
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
SpringJUnit5ConstructorInjectionTests(ApplicationContext applicationContext, @Autowired Person dilbert,
@Autowired Dog dog, @Value("${enigma}") Integer enigma, TestInfo testInfo) {
this.applicationContext = applicationContext;
this.dilbert = dilbert;
this.dog = dog;
this.enigma = enigma;
this.testInfo = testInfo;
}
示例7: test1
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@Test
@DisplayName("TEST 1")
@Tag("my-tag")
void test1(TestInfo testInfo) {
assertEquals("TEST 1", testInfo.getDisplayName());
assertTrue(testInfo.getTags().contains("my-tag"));
assertTrue(TestHelper.getLastRecordedStateForVariable("testInfo") != null);
}
示例8: loadFromExternalFile
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@DataProvider
static Object[][] loadFromExternalFile(TestInfo testInfo, TestReporter testReporter) {
checkNotNull(testInfo, "'testInfo' is not set");
checkNotNull(testReporter, "'testReporter' is not set");
String testDataFile = testInfo.getTestMethod().get().getAnnotation(ExternalFile.class).value();
// Load the data from the external file here ...
return new Object[][] { { testDataFile } };
}
示例9: testThree
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@ParameterizedTest
// @formatter:off
@DataProvider(value = {
"2 | 3 | 2, 3",
"c | d | c, d",
}, splitBy = "\\|")
// @formatter:on
void testThree(String a, String b, String expected, TestInfo testInfo) {
// Expect:
assertThat(testInfo.getDisplayName()).contains(expected);
}
示例10: testDivide
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@TestTemplate
@UseDataProvider
void testDivide(int dividend, int divisor, int result, TestInfo testInfo) {
// Expect:
assertThat(dividend / divisor).isEqualTo(result);
assertThat(testInfo.getDisplayName())
.endsWith(String.format("dividend=%d, divisor=%d, result=%d", dividend, divisor, result));
}
示例11: testThree
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@TestTemplate
// @formatter:off
@DataProvider(value = {
"2 | 3 | 2, 3",
"c | d | c, d",
}, splitBy = "\\|")
// @formatter:on
void testThree(String a, String b, String expected, TestInfo testInfo) {
// Expect:
assertThat(testInfo.getDisplayName()).contains(expected);
}
示例12: init
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@BeforeEach
void init(TestInfo testInfo) {
String displayName = testInfo.getDisplayName();
System.out.printf("@BeforeEach %s %n", displayName);
}
示例13: beforeEachTest
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@BeforeEach
default void beforeEachTest(TestInfo testInfo) {
log.info("About to execute {}", testInfo.getDisplayName());
}
示例14: afterEachTest
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@AfterEach
default void afterEachTest(TestInfo testInfo) {
log.info("Finished executing {}", testInfo.getDisplayName());
}
示例15: customDisplayName
import org.junit.jupiter.api.TestInfo; //导入依赖的package包/类
@RepeatedTest(value = 2, name = "{displayName} {currentRepetition}/{totalRepetitions}")
@DisplayName("Repeat!")
void customDisplayName(TestInfo testInfo) {
System.out.println(testInfo.getDisplayName());
}