blob: aa903d8f75da237cc4d03fb1620fbf1bc3222c80 [file] [log] [blame]
How to add a new annotation test using Junit
============================================
There are two ways to add new tests to annotation:
A. Add a new test by using golden files comparison:
--------------------------------------------------
1. make a new dir appserv-tests/deployment/annotation/<your new directory>
2. cp annotation/ejb/build.xml <your new directory>
3. modify ant project name in build.xml and test name under junit
4. create java files (ejbs, etc) for annotation testing in
<your new directory>/src
5. create a java files under devtests.util.AnnotationTest
import devtests.deployment.util.AnnotationTest;
public class InheritanceAnnotationTest extends AnnotationTest {
public InheritanceAnnotationTest(String name) {
super(name);
// you may need override ModuleType type here
}
}
Please make sure that the test class name is unique among these
annotation test. In general, I will prepend directory name.
6. put golden files for ejb-jar.xml, webservices.xml,etc under
<your new directory>/goldenfiles
7. update build.xml if necessary for classpath in targets: compile, test
8. update appserv-tests/deployment/annotation/build.xml to include your new test
B. Add a new test by testing explicit annotation info:
------------------------------------------------------
1. make a new dir appserv-tests/deployment/annotation/<your new directory>
2. cp annotation/webservice/build.xml <your new directory>
3. modify ant project name in build.xml
4. create java files (ejbs, etc) for annotation testing in
<your new directory>/src
5. create your new JUnit TestCase java class by
i) subclassing devtests.deployment.util.AnnotationTest
ii) include the following import statements:
import junit.framework.Assert;
import devtests.deployment.util.AnnotationTest;
iii) put all testing codes in one or more public methods with no parameter
method name starting with "test"
If you want your class compare golden files in addition to your
new tests, then please use a test name other than "testDescriptor".
If you don't want your class compare golden files, then please
have overrided the "testDescriptor" method.
iv) Inside the testing method, one can invoke the test assertion by
invoking static methods in Assert class.
For instance,
Assert.assertTrue(String errMsg, boolean condition);
Assert.assertNull(String errMsg, Object obj);
Assert.assertNotNull(String errMsg, Object obj);
Assert.assertEquals(int expected, int actual);
One find more details in junit javadoc.
6. update build.xml
i) classpath in targets: compile, test
ii) update the name attribute in test target to your new class:
<test name ="<your new class">
7. update appserv-tests/deployment/annotation/build.xml to include your new test
How to run the test:
--------------------
1. *** Due to an issue in ant
(http://ant.apache.org/faq.html#delegating-classloader),
we need to set CLASSPATH explicitly to include junit.jar in your environment
before running the test.
2. If you are using ant 1.5.4, then please also include xalan.jar version 2.0
or later in your classpath.
3. cd appserv-tests/deployment/annotation/
4. ant
How to view the result:
-----------------------
A short summary can be found in results.html.
The detailed test results can be found in
appserv-tests/deployment/annotation/report/html/index.html