Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing a method instead of testing a whole file in Netbeans w/ JUnit

I'm using Netbeans 6.8 and the finest-grained way to run my JUnit tests from the IDE appears to be to right-click a class under Test Packages and click Test File

In Eclipse it's possible to narrow the scope to testing an individual method in a given test harness. How do I test only one individual test out of a harness in Netbeans?

like image 747
Maciek Avatar asked Feb 03 '10 15:02

Maciek


People also ask

How do you test a method in JUnit?

A JUnit test is a method contained in a class which is only used for testing. This is called a Test class. To mark a method as a test method, annotate it with the @Test annotation. This method executes the code under test.

Which methods Cannot be tested by JUnit test class?

Which methods cannot be tested by the JUnit test class? Explanation: When a method is declared as “private”, it can only be accessed within the same class. So there is no way to test a “private” method of a target class from any JUnit test class.

What is the annotation used for testing your methods in Java?

The Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.


1 Answers

In NetBeans 7.1, open the unit test file, right click within the specific unit test and select "Run Focused Test."

like image 164
james.garriss Avatar answered Oct 21 '22 12:10

james.garriss