How to run all JUnit test cases from NetBeans?

情到浓时终转凉″ 提交于 2019-12-07 03:11:45

问题


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.


回答1:


Menu "Run/Test Project".




回答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:

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.



来源:https://stackoverflow.com/questions/1569008/how-to-run-all-junit-test-cases-from-netbeans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!