Load properties with JUnit 4 extension

PHOTO EMBED

Thu Aug 27 2020 11:19:39 GMT+0000 (Coordinated Universal Time)

Saved by @hosuaby #java

class MyTestClass {

    @Rule
    public PropertiesResource dbProperties = givenResource()
            .properties("/com/adelean/junit/jupiter/db.properties");

    @Test
    public void testWithJavaPropertiesResource() {
        assertThat(dbProperties.get())
                .containsEntry("db.user", "hosuaby")
                .containsEntry("db.password", "password")
                .containsEntry("db.url", "localhost");
    }
}
content_copyCOPY