Projects:TestGen4FAQ

Home | News | Requirements | Documentation | Screenshots | | Download | Forum | FAQ

Contents

Edit

How do I install TestGen4J?

Just extract from the zip for gz file

unzip testgen4j.0.1.4-alpha.zip

or

gunzip < testgen4j.0.1.4-alpha.tar.gz | tar xvf -

This will create a directory called testgen4j.0.1.4-alpha and all the files will be extracted in this directory. You should export two environment variables JAVA_HOME and JUNIT

$ export JAVA_HOME=/usr/java/j2sdk1.4.2_08
$ export JUNIT=/path/to/junit3.8.1/junit.jar

On Windows, set the environment variable like this:

c:\set JAVA_HOME=c:\path\to\j2sdk1.4.2_08>
c:\set JUNIT=c:\path\to\junit3.8.1\junit.jar

Edit

Where is my work space for TestGen4J?

Your work space is the root directory of TestGen4J /path/to/your/testgen4j.0.1.4-alpha/

Edit

How do I build test cases using TestGen4J?

TestGen4J can be used to build test cases from your class files, so you don't have to worry about using the source code. All you need is a jar of the class files for which you wish to build the test cases. For example you have a jar file by name myFile.jar Then you can build the test cases, simply by running the build.sh script and passing your jar file as a command line argument.

$ sh build.sh /complete/path/to/myFile.jar 

This will create a directory with the name myFile.tests, which is a combination of your file name and the string tests. The test code and the test data will be generated and built in this directory with the execution of above command.

Edit

What files are created after I build the test cases?

After you build the test cases as above the following test files are created in the directory myFile.tests

  • One test class file for each class of the source.
  • A PackageTestSuite class file which forms a test suite of the entire package.
  • data.xml, which contains the test case data in XML format. You can edit this XML file and add your own test case keeping the same XML schema.
  • A file LogTestCase.java, which is generated to log the failed and successful test cases while running.
  • A file ParseFailedDataFile.java, which is generated to parse the failed test cases after you run the test cases more than once.

Edit

How do I run test cases using TestGen4J?

Running test cases is equally simple. Just execute the run.sh shell script giving the same jar file as a command line argument for which you built the test cases.

$ sh run.sh /complete/path/to/myFile.jar 

You will be able to see the execution of all the test cases and also the successful and failed test cases are separated and stored in respective files in the same directory myFile.tests.

Edit

What files are created after I run the test cases?

After you run the test cases as above the following test files are created in the directory myFile.tests

  • TestSuccess.log, which logs all the successful tests.
  • TestFailure.log, which logs all the failed test cases.
  • failedData.xml, which separates the test data for failed test cases in XML format.

Edit

Can I run the test cases more than once after building the test cases only once?

Yes, you can run the test cases again after building the test cases only once. Building of test cases involves, generation of test code and test data. Since they are seperate, the test code will remain the same and you can edit the test data in data.xml and run the test cases again. Even if you don't edit the test data, TestGen4J will exclude the failed test cases logged in the earlier run.

Edit

Can I pass the generated test code through a Java code beautifier such as Jalopy?

Yes of course, you can pass the generated test code through a Java code beautifier like Jalopy. All you have to do is download jalopy-console-1.0.4. Go to the myFile.tests directory and beautify your code, like this:

$ java -jar /path/to/jalopy-console-1.0.4/lib/jalopy-console-1.0.4.jar *.java

Or, you can also use -d option to choose the destination directory where you wish to keep the beauitified code so that you do not have to go to the myFile.tests directory and then beautify the test code. To run using -d option:

$ java -jar /path/to/jalopy-console-1.0.4/lib/jalopy-console-1.0.4.jar myFile.tests/*.java

Edit

How do I test if TestGen4J is working?

After you build the test cases, there are 2 files created in myFile.tests directory. You can test if TestGen4J is working in the following way:

  • TestGenerated.log is the file created which will show you if TestGen4J successfully generated test code and test data.
  • TestCompiled.log is the file created which will show you if the test code is built successfully.

If any of these log files have errors, check if you have any dependent libraries for myFile.jar and may be they are not on the classpath.

Edit

Which license is TestGen4J released under?

TestGen4J is licensed under the Open Software License v.2.1.

Edit

Which platforms can I use TestGen4J on?

Starting from release 0.1 alpha, TestGen4J works out of the box on Linux, although it should also work on any platform that has a JDK and JUnit framework installed.

Edit

Where can I report problems or report feedback for TestGen4J?

Please visit the TestGen4J discussion forum hosted on the SpikeSource website for reporting bugs, feedback and general help.

Edit

What can TestGen4J not do?

TestGen4J can not generate test cases for interfaces and abstract classes, also neither for abstract methods. The User has to create the implementation of these to actually test them. In addition if there are any private constructors, in that case too the user needs to create those constructors. It also can not handle any inner classes, even if the return type of a method is an inner class object.

Edit

How good are the test cases generated by TestGen4J?

We applied TestGen4J on log4j-1.2.9, a popular Java application, and measured code coverage provided by the generated JUnit tests. The following are the reports:


--Maratmu


Top Level > Help > FAQ

MediaWiki

This page has been accessed 5,150 times.

This page was last modified 21:37, 7 April 2006.