Running unit test cases

Let's run this test case in Eclipse. Right-click on the file, or anywhere in the project in Package Explorer, and select the Run As | JUnit Test menu. Eclipse finds all unit tests in the project, executes them, and shows the results in the JUnit view:

Figure 5.4: JUnit results view

This view shows a summary of the test cases run. In this case, it has run one test case, which was successful. The green bar shows that all test cases were executed successfully.

Now, let's add one more check into the method:

 @Test public void testIsValidCourse() { ... //set empty course name course.setName(""); Assert.assertFalse(course.isValidCourse()); ...

Get Java EE 8 Development with Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.