This exercise helps you to understand how you can write nested test classes with JUnit 5. Also, after you have finished this exercise, you can understand the invocation order of setup, teardown, and test methods. You can finish this exercise by following these steps:
1. Open the NestedJUnit5Test
class which is found from the com.cleantestautomation.junit5intro
package.
2. Add a new nested test class called A
to the NestedJUnit5Test
class and configure the display name of the created nested test class.
3. Add a setup, teardown, and test method to the A
class. Implement these methods by writing unique ids to System.out
.
4. Add a new nested test class called WhenX
to the A
class and configure the display name of the created nested test class.
5. Add a setup, teardown, and test method to the WhenX
class. Implement these methods by writing unique ids to System.out
.
6. Add a new nested test class called WhenY
to the A
class and configure the display name of the created nested test class.
7. Add a setup, teardown, and test method to the WhenY
class. Implement these methods by writing unique ids to System.out
.
8. Run your tests and verify that the setup, teardown, and test methods are run in the expected order.