Coding JUnit tests (Simple)

In the previous recipe we have covered how to create a JUnit test case. Now we will code tests for the Employee class methods.

First of all you need to open the EmployeeTests class, which we have created in the previous recipe.

As you can see, the EmployeeTests class has a test() method with @Test above it. @Test is an annotation, which specifies that the current method is a single test. Before we start coding, let's find out what other annotations are available.

Besides @Test, there are:

  • @Before: Putting this annotation before the method means that this method will be executed before every test.
  • @After: Putting this annotation before the method means that this method will be executed after every test.
  • @Ignore: Putting this ...

Get Instant Eclipse Application Testing How-to now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.