This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to run JUnit test in Netbeans 4.0

 
Chris Johnston
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am trying out the new Netbeans 4.0 IDE and have hit a snag. Before giving up completely and going back to Eclipse, I thought I would ask for some help here.

I have a web project that I am working on using Tomcat 5 and setup as a proper J2EE web project in Netbeans. I am also using Hibernate. As such, I have created a few JUnit tests to run against my persisted objects and hibernate to ensure that the mappings are working correctly. However, I can not seem to get the tests to run within Netbeans. This is a very simple thing to do in Eclipse, but how do you do it in netbeans?

I can not find a "run junit test" button anywhere and the only things I can find to run the test results in an error message -- No servlet mapping in web.xml file.

Is this a limitation of Netbeans?
 
Chris Johnston
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case anyone cares, I don't think this is possible to do. I have tried every which way I can think of and I can not find any way of running JUnit tests on a standard java object in Netbeans if the project is configured as a web project.

In fact, I have found that Netbeans is severaly lacking in its support for JUnit. One definite strike against it when compared with Eclipse.

I personally like seeing that nice green line when all my tests pass, in Netbeans, I don't even get a line saying "All Tests: OK"
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris,
Thanks for sharing your experiences. I haven't used Netbeans, but I did come across this page. Have you seen it?
 
Chris Johnston
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have not seen that page, but I have seen all of the linked pages off that page pertaining to running JUnit in Netbeans 4.0. If you are working on a straight Java project, running JUnit is no problem. The steps outlined in the help files and other pages work great (although I have been unable to find any evidence of a nice little graphical Swing UI for JUnit). I have confirmed this by running JUnit tests against classes in a simply Java project.

The problem exists when you try to run JUnit tests for a web project. These simply do not work which makes no sense to me. I should be able to test straight Java classes with JUnit from within the IDE. However, this most basic ability is lacking in Netbeans 4.0.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic