Hi all,

Over the past couple of days I've merged a series of patches that upgrade the 
Engine's usage of JUnit to JUnit Jupiter 5.2 in order to make it easier to 
write new tests.

Despite the patches being quite straight-forward, since Jupiter is **not** 
backwards compatible to JUnit 4, or even JUnit 5 Vintage, here's the short 
version of what you need to know:

1. You no longer use annotations from the org.junit package, but the 
junit.org.jupiter.api packages. @Before and @After have been replaced with 
@BeforeEach and AfterEach respectively, and @BeforeClass and @AfterClass have 
been replaced with @BeforeAll and @AfterAll.

2. Assertions now live in the org.junit.jupiter.api.Assertions class. Note that 
the optional message parameter is now the **last** parameter in all the 
assertions, not the first. Also worth noting that assertThat has been removed. 
More often than not, assertTrue can be used with a Supplier<Boolean>, but if 
you absolutely need an assertThat method, just use the one that Hamcrest 
provides.

3. Similarly, assumptions live in org.junit.jupiter.api.Assumptions.

4. No more runners - extending tests in JUnit Jupiter is done with Extensions. 
There's no longer a need for the Parameterized and Theories runners, as you can 
just use the built-in @ParameterizedTest annotation. Instead of the 
MockitoJUnitRunner we used to heavily rely on, you should now use 
MockitoExtension.

5. No more Rules - these too were replaced with extensions. Our custom rules 
were replaced with extensions, which are pretty well documented both in their 
javadoc and in wiki under [1]

For additional information, you could take a look at the official documentation 
[2]


Happy testing!
Allon

[1] https://ovirt.org/develop/dev-process/unit-testing-utilities/
[2] https://junit.org/junit5/docs/current/user-guide/
_______________________________________________
Devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to