testsgen
Class GenerateTests

java.lang.Object
  |
  +--testsgen.GenerateTests

public class GenerateTests
extends java.lang.Object

GenerateTests.java is the main file which defines starter class for all actions performed by unit test generator. This class contains main() method where are recognized many command line parameters. I agree that should be created more user friendly GUI system for this test generator. I hope it will be ready for next version.
Below I described all available command line parameters with importance order. Developers should know that all these variables are available for modules as properties. All given command line parameters I put to global property list where from you can get it with System.getProperty() method.

  1. -cf, --config-file [file_name] As you can see there are a lot of possible parameters for running this application. Although almost all defaults are suitable for most cases if you use different options it is very difficult to run tool every time with long list of command line parameters.
    So you can put all parameters in file and use it each time you need. Default file name is 'gentest.cfg'. Content of this file should be of the following form:
     key = value
     
    Where key is name of command line parameter you want to set. You can also use there comments: Lines which starts with '#' character. and blank lines.
    If you use both config file and parameters in command line they will be processed in giving order. So last given parameter will be used during processing.
  2. -cp, -classpath, --classpath It is the most important parameter because this is only parameter which is always required.
    Since there is no way to set additional CLASSPATH during call: 'java -jar package.jar' here I provided parameter to set location of additional necessary classes. For example it is required to set location of jar file with compiled classes for sources found in '--input-directory' or set location of additional libraries for code parsers and generators like junit.jar. Please remember: if your project contains already some test classes you must put here jar file with compiled test classes. This allow analyze them and extend current test classes with additional test code for new created methods in source classes.
  3. -n --name-pattern pattern Pattern for creating names of test classes. The most commonly used standards are to put 'Test' string at the beginning of source class name or at the end of class name. If you have problems with wildchars in your environment you can write pattern as follows: 'Test*.java' or '*TestCase.java'.
  4. -o --output-directory dirname Store test files in this given directory.
    You can store your test files in different directories. There are two common used posibilities: store in the same directory tree where source classes are or create separated directory tree only for test classes. Please note that if you even put test classes in separated directory tree all related test classes will be always in the same packages where source classes are. It allow test classes to access to all non-private methods in source classes. It is good idea to test all non-private classes.
  5. -i --input-directory dirname Process files in given directory. But note that test classes will be searched in both input and output directories.
  6. -g --generate-method [empty|code|comments|both] Set here what you want to have in new generated test methods.
  7. -f --force Force overwriting existing files. And additionaly please note that new test classes will be always created in output directory even if they found in input directory.
  8. -b --build-update Allow overwriting existing files if they need updating. This parameter is required for extending existing test classes with new code. Whole existing code will be left unchanged And additionaly please note that new test classes will be always created in output directory even if they found in input directory.
  9. -m --file-mask mask Process files with given file mask.
  10. -r --recursive Recursive directories processing.
  11. -t --test-only Test only mode don't make any changes on disk.
  12. -q --quiet Don't display any messages on screen.
  13. -d --debug Display additional debug messages.
  14. -h --help Display help message and exit program.
  15. -v --version Display version info.
  16. -a --all-implementations package Package where are all modules implementations necessary for file processing.
  17. -u --target-unit-test full.class.name Name of class which generate code for unit test. It must be 'CodeGenIfc' implementation.
  18. -l --log-implementation full.class.name Name of class which implements logging facility. It must be 'LogIfc' implementation.
  19. -p --property-implementation full.class.name Name of class which implements property access facility. It must be 'PropertyIfc' implementation.
  20. -w --dir-walker-implementation full.class.name Name of class which provides file names list to process. It must be 'DirWalkerIfc' implementation.
  21. -s --src-parser-implementation full.class.name Name of class which parses source code. In other words it should provide list of preparsed structures which identifies source files. It must be 'SrcParserIfc' implementation.
  22. -c --code-gen-implementation full.class.name Name of class which generate code for unit test. It is synonym for --target-unit-test class.
Above list describes already implemented and used command line arguments. If you use additional packages implementing interfaces from this tool you must reference to proper documentation for info about additional command line parameters.

Created: Sat Dec 1 14:48:06 2001

Version:
$Revision: 1.19 $
Author:
Artur Hefczyc

Field Summary
protected  CodeGenIfc code_gen
           
protected  java.lang.String code_gen_impl
           
static java.lang.String created
           
protected  boolean debug
           
static java.lang.String dedicated
           
protected  java.lang.String def_impl
           
protected  DirWalkerIfc dir_walk
           
protected  java.lang.String dir_walk_impl
           
static java.lang.String INPUT_DIR
           
protected  java.lang.String local_class_path
           
protected  LogIfc log
           
protected  java.lang.String log_impl
           
static java.lang.String OUTPUT_DIR
           
protected  PropertyIfc property
           
protected  java.lang.String property_impl
           
protected  boolean quiet
           
protected  SrcParserIfc src_parser
           
protected  java.lang.String src_parser_impl
           
protected  java.lang.String target_unit
           
static java.lang.String version
           
 
Constructor Summary
GenerateTests()
           
GenerateTests(java.util.Properties prop)
           
GenerateTests(java.lang.String[] args)
           
 
Method Summary
protected  void addToProperties(java.lang.String key, java.lang.String value)
           
protected  int checkParameter(java.lang.String key, java.lang.String value)
           
protected  void displayHelp(java.lang.String option)
           
protected  void displayIntro()
           
protected  void displayVersion()
           
 void generateTests()
           
protected  void loadConfigFromFile(java.lang.String config_file)
           
protected  void loadConfigFromProperties(java.util.Properties prop)
           
protected  void loadImplementations()
           
protected static java.lang.String logo()
           
static void main(java.lang.String[] args)
           
protected  int parseBool(java.lang.String arg)
          parseBool method parses parameter which should be intepreted as boolean.
protected  void parseParams(java.lang.String[] args)
           
protected  void setDefs()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version

created

public static final java.lang.String created

dedicated

public static final java.lang.String dedicated

INPUT_DIR

public static final java.lang.String INPUT_DIR

OUTPUT_DIR

public static final java.lang.String OUTPUT_DIR

log

protected LogIfc log

property

protected PropertyIfc property

dir_walk

protected DirWalkerIfc dir_walk

src_parser

protected SrcParserIfc src_parser

code_gen

protected CodeGenIfc code_gen

quiet

protected boolean quiet

debug

protected boolean debug

def_impl

protected java.lang.String def_impl

target_unit

protected java.lang.String target_unit

log_impl

protected java.lang.String log_impl

property_impl

protected java.lang.String property_impl

dir_walk_impl

protected java.lang.String dir_walk_impl

src_parser_impl

protected java.lang.String src_parser_impl

code_gen_impl

protected java.lang.String code_gen_impl

local_class_path

protected java.lang.String local_class_path
Constructor Detail

GenerateTests

public GenerateTests()

GenerateTests

public GenerateTests(java.lang.String[] args)

GenerateTests

public GenerateTests(java.util.Properties prop)
Method Detail

generateTests

public void generateTests()

logo

protected static java.lang.String logo()

main

public static void main(java.lang.String[] args)

loadImplementations

protected void loadImplementations()

parseBool

protected int parseBool(java.lang.String arg)
parseBool method parses parameter which should be intepreted as boolean. for example debug option may be put as follows:
 app -d
 app -d 1 (or > 0)
 app -d 0
 app -d -1 (or < 0)
 app -d true
 app -d false
 app -d yes
 app -d no
 
All above posibilities should be intepreted in common sense.
Parameters:
arg - a String value of option followed by boolean parameter.
Returns:
an int value:
 -1 -- not found any interpretable value
 0  -- found false interpretation
 1  -- found true interpretation
 

addToProperties

protected void addToProperties(java.lang.String key,
                               java.lang.String value)

loadConfigFromFile

protected void loadConfigFromFile(java.lang.String config_file)

loadConfigFromProperties

protected void loadConfigFromProperties(java.util.Properties prop)

parseParams

protected void parseParams(java.lang.String[] args)

setDefs

protected void setDefs()

checkParameter

protected int checkParameter(java.lang.String key,
                             java.lang.String value)

displayIntro

protected void displayIntro()

displayVersion

protected void displayVersion()

displayHelp

protected void displayHelp(java.lang.String option)


Copyright GNU, wttools developers Team.