What is JTestCase ?

JUnit test framework provides an excellent way to formalize your test code. But due to its "none-input-param, none-return" design, generally you need to hard-code all test data for each testing method. And for each test cases of one unit test, you need to change test code, recompile it, and run it.

JTestCase that helps you in seperating test data from test code. You can organize all your test cases of multiple unit tests into one data file - an XML file, and bulk-load them into memory via sets of easy-to-use APIs that JTestCase provides. In a word, JTestCase provides a way for java unit tests to be test-case-oriented and full-test-automatable.

How does JTestCase works ?

Here is presented an introductory example to see how jtestcase works; this example is not a complete one (in the Getting Started section you can find a complete working example).

Suppose you have a method to sum two integers that you need to test.
Start with defining your test case using jtestcase XML format.

<method name="method_name">
	  <param_name="addend_1" type="int">1<param>
	  <param_name="addend_2" type="int">2<param>
	  <assert_name="result" type="int" action="EQUALS">3<assert>

In your junit test case, use the jtestcase API to pull data from the xml file; make a call to the method you want to test and make the assertions defined in the xml file using jtestcase assertion facility:

TestCaseInstance testCase = (TestCaseInstance) jtestcase.getTestCasesInMethod("myMethod").get(0);
HashMap params = testCase.getTestCaseParams();
int addend_1 = ((Integer) params.get("addend_1")).intValue();
int addend_2 = ((Integer) params.get("addend_2")).intValue();
int result = myCalculator.sum(addend_1,addend_2);
boolean success = testCase.assertTestVariable("result", new Integer(result));
assert("calculator sum failed", success);

If the result of the method call myCalculator.sum() equals 3 the test is asserted positively;
negatively otherwise.

This is the main idea behind the jtestcase tool. If you want to get more info, read in this site using the sidebar and/or contact the mailing lists.