How to run all JUnit test cases from NetBeans?
Asked Answered
M

2

6

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.

Motorcycle answered 14/10, 2009 at 21:7 Comment(0)
M
17

Menu "Run/Test Project".

Motorcycle answered 14/10, 2009 at 21:10 Comment(2)
What's going on here? Looks like rep gaining if you answer yourself the question after 3 minutes.Franny
Yes, this is really looks like rep gaining, but it is not the case. I posted the question and found the answer immediately after this. As you can see this is not hard. Just I think that this can be useful for somebody else. As you can see somebody voted up my response. More over it is not prohibited by stackoverflow, although initially i was not going to answer my own question :)Motorcycle
F
2

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.

Fr answered 17/7, 2012 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.