Home > Demo/Tutorial, Java > New Demo: Using JUnit in NetBeans 4.1

New Demo: Using JUnit in NetBeans 4.1

September 22nd, 2005

I have uploaded a new demo. This one is a very quick, very newbie centric introduction to using JUnit in NetBeans 4.1. Enjoy :-)

As an aside: you may notice some negative comments towards NetBeans in the demo, this is because JUnit integration is probably NetBeans poorest feature. Compared to Eclipse, NetBeans hardly integrates JUnit at all. However, it is still there and it is incredibly easy to use. And actually, the wizard that you use to create a test class does beat Eclipse. It is just the final output or reporting that you get from JUnit in NetBeans that sucks. I really miss the little green bar from Eclipse. Also, if you are using your own ant script, it is almost impossible to run a single test class. The limitations of Ant really do require that you run the entire suite of tests and for any real development, this can be a huge problem.

However, with all that said, please, enjoy the demo.

Categories: Demo/Tutorial, Java Tags:
  1. September 22nd, 2005 at 03:04 | #1

    Hi, graphical output for JUnit is prepared in NetBeans 5.0. I don’t think it’s perfect, but at least it’s a step forward. You won’t have to parse the plain text to find out if a test failed or not in 5.0.

  2. September 22nd, 2005 at 08:28 | #2

    Very cool. Will there be the ability to run a single JUnit test without having to figure out how to code that capability into an Ant script?

  3. September 22nd, 2005 at 09:44 | #3

    You can run the test from the projects context menu. Right-click on the test and choose Run File. This launches a single test. No need to change ant scripts for running single tests…

  4. September 22nd, 2005 at 11:20 | #4

    Oh I see, your question is about running a single test from a free-form project, right?

  5. September 22nd, 2005 at 12:36 | #5

    Yep. Right now, if you use the ant scripts that NetBeans generates you can test a single class. However, if you use a free-form project, this is a very difficult thing to set up. I have looked at the NetBeans ant scripts that allow for this functionality and can’t make any sense out of them. I am not sure if this is due to functionality being hidden in the xml schema that NetBeans uses or not.

    It would be very nice to integrate the ability to run individual test classes into the IDE. This would make working with free-form projects a lot easier.

    One project I was working on, in order to test just my code I had to switch to Eclipse. If I tried to test my code using NetBeans and my own ant scripts, the script would never get to my test cases as someone else’s would fail. This inability to run single test classes (or random test classes) was the only “but” that my team came across when working with NetBeans. And it made it very difficult for people to test their own code.

  6. May 31st, 2006 at 15:05 | #6

    thankyou very much for your tutorial

  7. socrates
    July 27th, 2008 at 13:06 | #7

    Thank you for this fine tutorial. I will send my students to watch it.

Comments are closed.