From the course: Java: Testing with JUnit
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Nested tests
- We have just seen test execution and how we can influence the order of our tests. With nested tests we can control the relationship between tests. This can, for example, be useful when you would want to separate a certain feature or a specific methods and organize your code around it. It is often also used to execute, in case of certain conditions, such as when you, when something is not found, when something is found, and for example, when exception gets thrown. Let's move over to Intelli J and do this for when balance is zero. We're going to group all the scenarios we want to test for the situation in our nested class. Let's first create a class for this, bank account, nested test. Alright, and we will start off by giving our class the same content as our regular bank content. We had to withdraw any depths admits in there, and it's a great place to start. So I'm just going to be coping all the content of this class…