JavaTest Template
 

Woking on similar lines as JavaSpec, this template generator parses an
input Class file and creates unique Test Template Files for
each public method complying with all combinations of its parameter list.
It is mainly used for doing a white box testing for all API's (methods).

This will ensure that all Java Testcase Files follow a given template.

It uses reflection to figure out all constructors and public methods
for a given class.
The file-naming convention for output files is a straight forward one.
[class Name]_[method name]_[param combinations].java

param combinations is based on all permutations depending on the values
of different data types (as listed below)
 

Listed below is all possible values for types of parameter.
 
String (null, "DUMMY_STRING")
int (0, Integer.MIN_VALUE, Integer.MAX_VALUE)
float (0, Float.MIN_VALUE, Float.MAX_VALUE)
double (0, Double.MIN_VALUE, Double.MAX_VALUE)
long (0, Long.MIN_VALUE, Long.MAX_VALUE)
short (0, Short.MIN_VALUE, Short.MAX_VALUE)
char (Character.MAX_VALUE)
boolean (true, false)
byte (Byte.MIN_VALUE, Byte.MAX_VALUE)
Integer (null, 0, Integer.MIN_VALUE, Integer.MAX_VALUE)
Float  (null, 0, Float.MIN_VALUE, Float.MAX_VALUE)
Double (null, 0, Double.MIN_VALUE, Double.MAX_VALUE)
Long (null, 0, Long.MIN_VALUE, Long.MAX_VALUE)
Short (null, 0, Short.MIN_VALUE, Short.MAX_VALUE)
Character (null, Character.MAX_VALUE)
Byte (null, Byte.MIN_VALUE, Byte.MAX_VALUE)
Object (null, "NOTNULL")

So for a method 'm' for class 'c' with two String parameters the output files generated will be
c_m_String_String_0.java --> (null, null)
c_m_String_String_1.java --> ("DUMMY_STRING", null)
c_m_String_String_2.java --> (null, "DUMMY_STRING")
C_m_String_String_3.java --> ("DUMMY_STRING", "DUMMY_STRING")


How to run


java BWJavaTestTemplate [ -d ] classname
is the location where u want to generate these
TestCase files


Example

Class: x.java

   public class x
   {
      public x(String arg)
      {
      }

     private void modifyVal(String instr)
     {
     }

     public void setVal (String ival)
     {
     }

     public void setIndexVal (String ival, int index)
     {
     }
  }
 

Generated Files are
    x_setVal_String_0.java
    x_setIndexVal_String_int_0.java
    x_setIndexVal_String_int_1.java
    x_setIndexVal_String_int_2.java
    x_setIndexVal_String_int_3.java
    x_setIndexVal_String_int_4.java
    x_setIndexVal_String_int_5.java
    x_x_String_0.java
    x_x_String_1.java
    x.txt


NOTE

Right now the author name in each of those generated files is left  empty. Future version will reflect the same from configuration files.