Tuesday, December 05, 2006

UnitTesting:JTestcase and Jetif

JTestcase is an open source software which takes the Testdata in an XML format and generates the testcases automatically. It have a no of simple APIs which we need to use to extract the testdata from the XML file and use them in the Testcase file.
Once testcase gets created, then without changing the Testcase java file, we can keep adding the Testdata in the XML file. So this separates the Testdata and the Testcase java file.

Jetif is a higher level open source software which requires very little code to be written as compared to Junit and JTestcase.

Below table shows the feature difference between Jetif and JUnit + JTestCase.

Feature Jetif JUnit + JTestCase
Sepearate test code and data Supported by Handler Supported by JTestCase or other mechanism
Parameters & Return Value Supported by Handler No
Logging Yes Supported by extension
DataTypes Limited built-in supported, extendable by user Limited supported
Client/Server Testing Yes Supported by extension

Code Comparison

You can create more straightforward test code with Jetif, because the parameters and return value in test method are supported by Jetif. For example, a test method can be writtern as below with Jetif:

public boolean testSomething(float param1, String[] param2, Integer param3){
// Test something with the param1, param2, param3
return true;

While a test method can only be writtern as below with JUnit + JTestCase:

public void testSomething() {
// get the test cases from XML
Vector testCases = _jtestcase.getNameOfTestCases("testSomething");
// for each test case execute
With Jetif, you can define the parameters and expected return value in spec file, and then just use them as parameters and return a value what you want in test code, it's more simple and more clear than JUnit.


1 comment:

Vale Co Xenia said...

Very much useful article. Kindly keep blogging

Java Training in Chennai

Java Online Training India