0 points

Load properties with JUnit 4 extension


dashboard

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

Posted 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_copy Copy