TestList

Description

This task sets the specified property to the list of test cases to run. List of test cases is created based on given J2ME application or classes and/or java source files specified via test descriptions. Test cases included are classes and/or java source files that implement momeunit.framework.Test interface and/or match specified pattern.

Tests can be described by using <testdir>, <tesjar> nested tags. <testlist> task is an implicit test and can be described using testdir, testtype and testjar attributes.

Users can use pattern to further refine list of test cases to run. Format of pattern resembles Ant path pattern. Instead of slash ('/'), dot ('.') is used. It looks like ant package pattern ( e.g. "**.*Test" matches any file that ends with Test at any package, "test.**.*" matches any file below test package, "**.*" matches all files).

Java source files will be compiled to test that they implement Test interface.

The value of set property is intended to be used for building and/or running test application using other tasks (e.g. from antenna project).

Attributes

Attribute

Description

Required

appjar

Jar file of J2ME application to scan for tests. If set all tests descriptions are ignored.

No

classpath

Classpath to use. The default is ant-momeunit.jar, midp[version] and cldc[version] libraries. Specified classpath is added to the default one.

No

config

CLDC version to use.

Note: The least version <testlist> supports now is "1.1" (the default one).

No; default is "1.1"

defpatten

Pattern to be used as default for nested <testdir>, <testjar> tags and implicit test. The default is to allow all classes.

No; default is "**.*"

onlyTests

Include in tests list classes specified by implicit test or appjar only if they implement momeunit.framework.Test interface.

No; default is on.

pattern

Pattern to refine list of test cases of implicit test. The format of this pattern resembles Ant path pattern. Instead of slash ('/'), dot ('.') is used. It looks like ant package pattern ( e.g. "**.*Test" matches any file that ends with Test at any package, "test.**.*" matches any file below test package, "**.*" matches all files). The default value is specified by defpattern attribute.

Note: Only files implementing momeunit.framework.Test interface are enlisted (depends on onlyTests attribute).

No

profile

MIDP version to use.

Note: The least version <testlist> supports now is "2.0" (the default one).

No; default is "2.0"

property

Name of the property to set to list of test cases to run separated by separator.

Yes

separator

Character used for separating test cases in created list. The default value is comma (",").

No; default is ","

testdir

Root directory of classes or source java files to be scanned for test cases.

Note: Java source files will be compiled to test that they implement Test interface.

Either one of them or appjar or nested <testdir> or <testjar> tags.

testjar

Jar file to be scanned for test cases.

testtype

Type of files specified by testdir attribute. Either "class" (the default) or "src".

  1. "class" indicates that testdir specifies classes root directory.

  2. "src" indicates that testdir specifies source root directory.

Note: Can be used only in conjunction with testdir attribute.

No; default is "class"

tmpdir

Directory where testlist should place temporary files. By default uses "tmp.dir" ant property. If not set uses "java.io.tmpdir" java system property.

No

wtkhome

Home directory of WTK used. If not set uses "wtk.home" ant property. If not set uses WTK_HOME environment variable.

No


Nested Elements of testlist

classpath

The location of class files to be used at compiling java source files can be specified using this PATH like structure.


compiler

Configures compiler that compiles java source files, if there are some. This tag extends <javac> task, All attributes and nested tags of <javac> except forbidden in compiler can be specified.

compiler forbids following attributes:

  1. classpath, classpathref – classpath of testlist is used instead;

  2. src, sourcepath, sourcepathref - sources specified by testdir tags and testdir attribute of testlist are used instead;

and nested tags:

  1. classpath – classpath of testlist is used instead;

  2. src, sourcepath - sources specified by testdir tags and testdir attribute of testlist are used instead;

Note: target attribute is preset to 1.1 and source attribute is preset to 1.3.

Additional attributes defined in compiler:

Attribute

Description

Required

destdir

Directory where to place compiled classes. Defaults to temporary directory under tmpdir.

No

delonexit

Delete compiled classes after tests run. Default is on, unless destdir is set.

Note: Users should be careful with specifying this attribute. if destdir is set and delonexit is set to true destdir will be deleted with it's content after tests run.

No


testdir

Defines classes to be scanned for tests cases. This tag extends fileset. All attributes and nested tags of fileset are allowed. Only files designated by this tag are scanned for test cases.

Attribute

Description

Required

dir

Directory of files to be scanned for test cases. Files below this directory will be compiled if necessary.

Yes

type

Type of files under dir. Either "src" or "class". The default value is "class".

No; default is "class"

pattern

Pattern to refine test cases enlisted. The format of this pattern resembles Ant path pattern. Instead of slash ('/'), dot ('.') is used. It looks like ant package pattern. ( e.g. "**.*Test" matches any file that ends with Test at any package, "test.**.*" matches any file below test package, "**.*" matches all files). The default value is specified by defpattern attribute of <testlist>.

Note: Only files implementing momeunit.framework.Test interface are enlisted (depends on onlyTests attribute).

No

onlyTests

Include only classes that implement momeunit.framework.Test interface in tests list.

No

if

Only run tests if the named property is set.

No

unless

Only run tests if the named property is not set.

No


testjar

Defines classes to be scanned for tests cases. This tag extends zipfileset. All attributes and nested tags of zipfileset are allowed. Only files designated by this tag are scanned for test cases.

Attribute

Description

Required

src

Jar file to be scanned for test cases.

Yes

pattern

Pattern to refine test cases enlisted. The format of this pattern resembles Ant path pattern. Instead of slash ('/'), dot ('.') is used. It looks like ant package pattern. ( e.g. "**.*Test" matches any file that ends with Test at any package, "test.**.*" matches any file below test package, "**.*" matches all files). The default value is specified by defpattern attribute of <testlist>.

Note: Only files implementing momeunit.framework.Test interface are enlisted (depends on onlyTests attribute).

No

onlyTests

Include only classes that implement momeunit.framework.Test interface in tests list.

No

if

Only run tests if the named property is set.

No

unless

Only run tests if the named property is not set.

No


Examples

  <testlist property="testlist" appjar="res/myapp.jar" />

Sets testlist property to a list of test names of all classes of myapp.jar that implement momeunit.framework.Test interface.

  <testlist property="testlist" appjar="res/myapp.jar" separator=";" />

Does the same as previous example but tests are separated by semicolon instead of comma.

  <testlist property="testlist" testdir="src" testtype="src" />

Sets testlist property to a list of test names of all java source files under src directory that implement momeunit.framework.Test interface. Compiles java source files before.

  <testlist property="testlist" >
    <testdir dir=src" type="src" />
  </testlist>

Does the same as previous example.

  <testlist property="testlist" testdir="src" pattern="**.*Test" onlyTest="off" />

Sets testlist property to a list of test names of all classes under src directory that ends on Test. Doesn't test classes for implementing momeunit.framework.Test interface.

<target name="buildApp" ... >

  ...

  <testlist property="testlist" testdir="bin" />

  ...
  
  <wtkjad ... >
    
    ...
    
    <attribute name="MoMEUnit-Tests" value="${testlist}"/>
    <attribute name="MoMEUnit-TestsName"" value="MyApp"/>
    <midlet name="MIDletTestRunner" class="momeunit.runner.MIDletTestRunner" />    
    ...
    
  </wtkjad>
  
  ...

</target>

Sets testlist property to a list of test names of all classes under bin directory that implement momeunit.framework.Test interface. Makes JAD descriptor for running tests by MIDletTestRunner using antenna tasks.