THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
@Test @DisabledOnEnvironment({"dev", "prod"}) void testFail() { fail("this test fails"); } |
Now it becomes available to define parameters for test constructors and methods and use dependency injection for them. With ParameterResolver class we can resolve parameters in runtime.
At the time of this writing there are 3 built-in parameter resolvers: TestInfo, RepetitionInfo, TestReporter. Example for one of them:
Code Block |
---|
@Test
@DisplayName("Test Get Users")
public void testGetUsersNumberWithInfo(TestInfo testInfo) {
// test logic.
logger.info("Running test method:" + testInfo.getTestMethod().get().getName());
} |
Migration from JUnit 4 to 5 is not so difficult, as backward compatibility is available.
...