0 points

Load properties with JUnit 5 extension


dashboard

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

Posted by @hosuaby #java

@TestWithResources
class InjectPropertiesResourcesTests {

    @GivenPropertiesResource("/com/adelean/junit/jupiter/db.properties")
    Properties dbProperties;

    @Test
    public void testInjectTextIntoStringInstanceField() {
        assertThat(dbProperties)
                .containsEntry("db.user", "hosuaby")
                .containsEntry("db.password", "password")
                .containsEntry("db.url", "localhost");
    }
}
content_copy Copy