0 points

Load text with JUnit 5 extension


dashboard

Thu Aug 27 2020 11:11:22 GMT+0000 (UTC)

Posted by @hosuaby #java

@TestWithResources  // <-- add extension
public class InjectTextResourcesTests {

    @GivenTextResource("/com/adelean/junit/jupiter/resource.txt")
    String resourceContent;   // <-- inject resource content

    @Test
    public void testInjectTextIntoStringInstanceField() {
        assertThat(resourceContent)
                .isEqualTo("The quick brown fox jumps over the lazy dog.");
    }
}
content_copy Copy