From the course: Java for All Platforms: Desktop, Web, and Mobile Development

Unlock the full course today

Join today to access over 23,500 courses taught by industry experts.

Creating unit tests

Creating unit tests

- [Instructor] One of the fundamental tools in your tool belt as a Java developer is unit tests. Unit tests allow you to test that the code that you wrote does what you claim it does. This can be extremely useful the larger your applications get. You can use them to confirm that your algorithms and logic give you the intended results. Let's take a very simple example to look at unit tests here. I have a class called number helper that has a method that adds two numbers together and returns the sum. We're going to write unit tests to confirm that the sums are what we expect in certain cases. Now we're going to use some IntelliJ features to automatically generate unit tests. Right click the method name, and then choose generate and choose test. Here we see a message that says no test roots are found. I'll create one by clicking okay. I'm going to use JUnit5 for the testing library. I'll leave the class name number helper…

Contents