Search

Saturday, April 17, 2010

What is JUnit ? What is coding convention of Unit test case class?

1. JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development (Agile).

2.  Following are coding convention to wirte test class :

Coding Convention :
   
             1. Name of the test class must end with "Test".
                2. Name of the method must begin with "test".
                3. Return type of a test method must be void.
                4. Test method must not throw any exception.
                5. Test method must not have any parameter.


i.e : 
Normal Version : 

class Employee { public String name (String name) {return name;}}

Junit test case version :
class EmployeeTest extends TestCase {
Employee   e = new Employee();
public void testName() {
assertEquals("kapil " , e.name("kapil"));
}
}

No comments:

Post a Comment