TaT SwitchTestAndClassNB65

Revision as of 16:46, 5 November 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Switch between class and test in NetBeans

Contributed by: Hubert A Klein Ikkink


Reposted from this blog entry: http://mrhaki.blogspot.com/2009/05/switch-between-class-and-test-in.html

Tips and Tricks

When we have a Java class in our NetBeans project with a corresponding JUnit test class we can easily switch between them. When we are editing our Java class file and want to go to the test class we select Navigate | Go to Test (Ctrl+Shift+T in Windows). NetBeans jumps to our test class!

To go the other way, we must have our test class open. Now we select Navigate | Go to Tested Class (Ctrl+Shift+T in Windows) and NetBeans jumps to the Java class.

NetBeans assumes the name of the test class starts with the Java class name we want to test, and the package in which both the test class and Java class reside are the same. So for example if we have a Java class com.mrhaki.netbeans.Sample, the test class must be com.mrhaki.netbeans.SampleTest. The files don't have to be in the same directory structure. So the sources can be in a src/ directory and the test classes in a test/ directory.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo