ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Using JUnit With Eclipse IDE
Subject:   junit naming conventions
Date:   2004-02-21 02:15:19
From:   sundling
This article is in contrast to what I have normally seen for junit naming conventions. Generally the class name for a unit test is the name of the java class with Test before or after. So if the class under test is HelloWorld, the test case class would be HelloWorldTest (or TestHelloWorld if you prefered). Then the methods inside that class HelloWorldTest could be testThatWeGetHelloWorldPrompt. If our Hello World program took an argument, then we might also have a testNullWorld method to test that a null argument is handled properly.


One organizational step beyond that is to keep junit and source files in seperate, parallel directories, as in
/src/java/com/mysite/HelloWorld.java
/src/test/com/mysite/HelloWorldTest.java
as preferred jakarta practice.