Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run all JUnit test cases from NetBeans?

I have created several files with unit tests on existing classes in NetBeans project. I used menu "File/New file/JUnit/Test for Existing Class" to create test files.

I can run one file with unit tests by right click on it and select "Run File".

But I want to run all files with unit tests. How can I achieve this in the simplest way?

I am using NetBeans 6.5.

like image 508
sergtk Avatar asked Oct 14 '09 21:10

sergtk


2 Answers

Menu "Run/Test Project".

like image 81
sergtk Avatar answered Nov 10 '22 01:11

sergtk


In NetBeans 7.1 you can create a test suite, to which you can add as many of your JUnit test files as you want. When you run the suite, you run all the files in the suite.

To create the test suite, create a file like any other:

enter image description here

In the main class add your test classes like this:

@RunWith(Suite.class)
@Suite.SuiteClasses(
{
    com.somewhere.myProject.MyFirstTestClass.class, 
    com.somewhere.myProject.MySecondTestClass.class, 
    com.somewhere.myProject.MyThirdTestClass.class  
})

To run, right click this file in the Projects windows and select Test File.

like image 28
james.garriss Avatar answered Nov 10 '22 03:11

james.garriss