O'Reilly logo

NetBeans IDE 8 Cookbook by Rhawi Dantas, David Salter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a JUnit test for an existing class

NetBeans provides facilities to easily create JUnit tests. In this recipe, we'll see how we can create tests for an existing class. We'll initially create a new library project within NetBeans and create a very simple class to do some basic math. We'll then see how to use NetBeans to create tests for the library.

Getting ready

To complete this recipe, you need to ensure that you have installed the JUnit support into NetBeans as described in the previous recipe, Installing JUnit support into NetBeans.

How to do it…

To create a JUnit test for an existing class, perform the following steps:

  1. Click on File and then New Project.... Create a new Java Class Library project called Calculator. If you are unsure of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required