Java 类org.junit.jupiter.api.TestInfo 实例源码

项目:roboslack    文件:EnrichTestMessageRequest.java   
@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();
}
项目:mastering-junit5    文件:TestInfoTest.java   
@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());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:TestInfoTest.java   
@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());
}
项目: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)));
}
项目:spring-test-junit5    文件:SpringExtensionTests.java   
@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");
}
项目:spring-test-junit5    文件:SpringJUnit5ConstructorInjectionTests.java   
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;
}
项目:scott    文件:TestInfoTest.java   
@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);
}
项目:junit-dataprovider    文件:DataProviderMethodParameterAcceptanceTest.java   
@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 } };
}
项目:junit-dataprovider    文件:AdditionalTestMethodParameterAcceptanceTest.java   
@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);
}
项目:junit-dataprovider    文件:FormatAcceptanceTest.java   
@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));
}
项目:junit-dataprovider    文件:AdditionalTestMethodParameterAcceptanceTest.java   
@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);
}
项目:junit-dataprovider    文件:DataproviderMethodParameterAcceptanceTest.java   
@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 } };
}
项目:mastering-junit5    文件:TestInfoTest.java   
@BeforeEach
void init(TestInfo testInfo) {
    String displayName = testInfo.getDisplayName();
    System.out.printf("@BeforeEach %s %n", displayName);
}
项目:mastering-junit5    文件:TestLifecycleLogger.java   
@BeforeEach
default void beforeEachTest(TestInfo testInfo) {
    log.info("About to execute {}", testInfo.getDisplayName());
}
项目:mastering-junit5    文件:TestLifecycleLogger.java   
@AfterEach
default void afterEachTest(TestInfo testInfo) {
    log.info("Finished executing {}", testInfo.getDisplayName());
}
项目:mastering-junit5    文件:TunningDisplayInRepeatedTest.java   
@RepeatedTest(value = 2, name = "{displayName} {currentRepetition}/{totalRepetitions}")
@DisplayName("Repeat!")
void customDisplayName(TestInfo testInfo) {
    System.out.println(testInfo.getDisplayName());
}
项目:mastering-junit5    文件:TunningDisplayInRepeatedTest.java   
@RepeatedTest(value = 2, name = RepeatedTest.LONG_DISPLAY_NAME)
@DisplayName("Test using long display name")
void customDisplayNameWithLongPattern(TestInfo testInfo) {
    System.out.println(testInfo.getDisplayName());
}
项目:mastering-junit5    文件:TunningDisplayInRepeatedTest.java   
@RepeatedTest(value = 2, name = RepeatedTest.SHORT_DISPLAY_NAME)
@DisplayName("Test using short display name")
void customDisplayNameWithShortPattern(TestInfo testInfo) {
    System.out.println(testInfo.getDisplayName());
}
项目:Building-Web-Apps-with-Spring-5-and-Angular    文件:UserAccountControllerTest.java   
@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
    this.mockMvc = MockMvcBuilders.standaloneSetup(new UserAccountController(this.userService, this.docService)).build();
    String displayName = testInfo.getDisplayName();
    assertTrue(displayName.equals("Should return error message for when user not existing in the database tries to login."));
}
项目:Building-Web-Apps-with-Spring-5-and-Angular    文件:UserAccountControllerTest.java   
@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
    this.mockMvc = MockMvcBuilders.standaloneSetup(new UserAccountController(this.userService, this.docService)).build();
    String displayName = testInfo.getDisplayName();
    assertTrue(displayName.equals("Should return error message for when user not existing in the database tries to login."));
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:TestInfoTest.java   
@BeforeEach
void init(TestInfo testInfo) {
    String displayName = testInfo.getDisplayName();
    System.out.printf("@BeforeEach %s %n", displayName);
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:TestLifecycleLogger.java   
@BeforeEach
default void beforeEachTest(TestInfo testInfo) {
    log.info("About to execute {}", testInfo.getDisplayName());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:TestLifecycleLogger.java   
@AfterEach
default void afterEachTest(TestInfo testInfo) {
    log.info("Finished executing {}", testInfo.getDisplayName());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:TunningDisplayInRepeatedTest.java   
@RepeatedTest(value = 2, name = "{displayName} {currentRepetition}/{totalRepetitions}")
@DisplayName("Repeat!")
void customDisplayName(TestInfo testInfo) {
    System.out.println(testInfo.getDisplayName());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:TunningDisplayInRepeatedTest.java   
@RepeatedTest(value = 2, name = RepeatedTest.LONG_DISPLAY_NAME)
@DisplayName("Test using long display name")
void customDisplayNameWithLongPattern(TestInfo testInfo) {
    System.out.println(testInfo.getDisplayName());
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:TunningDisplayInRepeatedTest.java   
@RepeatedTest(value = 2, name = RepeatedTest.SHORT_DISPLAY_NAME)
@DisplayName("Test using short display name")
void customDisplayNameWithShortPattern(TestInfo testInfo) {
    System.out.println(testInfo.getDisplayName());
}
项目:pdfcompare    文件:IntegrationTest.java   
@BeforeEach
public void before(TestInfo testInfo, @TempDirectory(parentPath = ".") Path outDir) throws IOException, InterruptedException {
    testName = testInfo.getTestMethod().get().getName();
    this.outDir = outDir;
}
项目:demo-junit-5    文件:ArgumentSourcesTest.java   
@ParameterizedTest
@ValueSource(strings = { "Hello", "JUnit" })
void withOtherParams(String word, TestInfo info, TestReporter reporter) {
    reporter.publishEntry(info.getDisplayName(), "Word: " + word);
    assertNotNull(word);
}
项目:junit5-samples    文件:MockitoExtensionInBaseClassTest.java   
@BeforeEach
void initialize(@Mock MyType myType, TestInfo testInfo) {
    when(myType.getName()).thenReturn(testInfo.getDisplayName());
    when(numberGenerator.next()).thenReturn(42);
}
项目:scott    文件:InterfaceTestHelper.java   
@BeforeEach
default void beforeEachTest(TestInfo testInfo) {
}
项目:scott    文件:InterfaceTestHelper.java   
@AfterEach
default void afterEachTest(TestInfo testInfo) {
}
项目:junit-dataprovider    文件:AdditionalTestMethodParameterAcceptanceTest.java   
@ParameterizedTest
@UseDataProvider
void testObjectArrayArray(Object a, Object b, String expected, TestInfo testInfo) {
    // Expect:
    assertThat(testInfo.getDisplayName()).contains(expected);
}
项目:junit-dataprovider    文件:AdditionalTestMethodParameterAcceptanceTest.java   
@ParameterizedTest
@UseDataProvider
void testObjectArray(Object a, TestInfo testInfo) {
    // Expect:
    assertThat(testInfo.getDisplayName()).contains("a");
}
项目:junit-dataprovider    文件:AdditionalTestMethodParameterAcceptanceTest.java   
@TestTemplate
@UseDataProvider
void testObjectArrayArray(Object a, Object b, String expected, TestInfo testInfo) {
    // Expect:
    assertThat(testInfo.getDisplayName()).contains(expected);
}
项目:junit-dataprovider    文件:AdditionalTestMethodParameterAcceptanceTest.java   
@TestTemplate
@UseDataProvider
void testObjectArray(Object a, TestInfo testInfo) {
    // Expect:
    assertThat(testInfo.getDisplayName()).contains("a");
}