Skip to content

Commit 0da3cfd

Browse files
author
osmanjisy
committed
starting of test framework
1 parent e9cc5a4 commit 0da3cfd

21 files changed

Lines changed: 184 additions & 4 deletions

.classpath

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="src/main/java"/>
4+
<classpathentry kind="src" path="src/test/java"/>
45
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6+
<classpathentry kind="lib" path="lib/test/hamcrest-core-1.3.jar"/>
7+
<classpathentry kind="lib" path="lib/test/junit-4.12.jar"/>
8+
<classpathentry kind="lib" path="lib/test/asm-5.0.1.jar"/>
9+
<classpathentry kind="lib" path="lib/test/asm-analysis-5.0.1.jar"/>
10+
<classpathentry kind="lib" path="lib/test/asm-commons-5.0.1.jar"/>
11+
<classpathentry kind="lib" path="lib/test/asm-tree-5.0.1.jar"/>
12+
<classpathentry kind="lib" path="lib/test/asm-util-5.0.1.jar"/>
13+
<classpathentry kind="lib" path="lib/test/cobertura-2.1.1.jar"/>
14+
<classpathentry kind="lib" path="lib/test/commons-lang3-3.3.2.jar"/>
15+
<classpathentry kind="lib" path="lib/test/jaxen-1.1.4.jar"/>
16+
<classpathentry kind="lib" path="lib/test/jetty-6.1.14.jar"/>
17+
<classpathentry kind="lib" path="lib/test/jetty-util-6.1.14.jar"/>
18+
<classpathentry kind="lib" path="lib/test/logback-classic-1.0.13.jar"/>
19+
<classpathentry kind="lib" path="lib/test/logback-core-1.0.13.jar"/>
20+
<classpathentry kind="lib" path="lib/test/oro-2.0.8.jar"/>
21+
<classpathentry kind="lib" path="lib/test/servlet-api-2.5-6.1.14.jar"/>
22+
<classpathentry kind="lib" path="lib/test/slf4j-api-1.7.5.jar"/>
523
<classpathentry kind="output" path="build-eclipse"/>
624
</classpath>

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/build-eclipse/
22
/build/
3+
cobertura.ser
4+
.DS_Store
5+
/dist/

build.xml

Lines changed: 135 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,41 @@
33
<property name="src.dir" value="src/main" />
44
<property name="src.java.dir" value="${src.dir}/java" />
55

6+
<property name="test.dir" value="src/test" />
7+
<property name="test.java.dir" value="${test.dir}/java" />
8+
69
<property name="build.dir" value="build" />
10+
<property name="build.classes.dir" value="${build.dir}/classes" />
711
<property name="dist.dir" value="dist" />
812

13+
<property name="build.reports.dir" value="${build.dir}/reports" />
14+
15+
<property name="junit.reports.dir" value="${build.reports.dir}/junit" />
16+
<property name="junit.reports.xml.dir" value="${junit.reports.dir}/xml" />
17+
<property name="junit.reports.html.dir" value="${junit.reports.dir}/html" />
18+
19+
<property name="junit.test.pattern" value="**/*Test.java" />
20+
21+
<property name="cobertura.reports.dir" value="${build.reports.dir}/cobertura" />
22+
<property name="cobertura.reports.xml.dir" value="${cobertura.reports.dir}/xml" />
23+
<property name="cobertura.reports.html.dir" value="${cobertura.reports.dir}/html" />
24+
25+
<property name="lib.dir" value="lib" />
26+
<property name="lib.test.dir" value="${lib.dir}/test" />
27+
28+
<property name="build.test.classes.dir" value="${build.dir}/test/classes" />
29+
<property name="cobertura.instrumented.dir" value="${build.dir}/test/instrumented-classes" />
30+
931
<target name="init">
10-
<mkdir dir="${build.dir}" />
32+
<mkdir dir="${build.classes.dir}" />
33+
<mkdir dir="${build.test.classes.dir}" />
1134
<mkdir dir="${dist.dir}" />
35+
36+
<mkdir dir="${junit.reports.xml.dir}" />
37+
<mkdir dir="${junit.reports.html.dir}" />
38+
39+
<mkdir dir="${cobertura.reports.xml.dir}" />
40+
<mkdir dir="${cobertura.reports.html.dir}" />
1241
</target>
1342

1443
<target name="clean">
@@ -17,12 +46,114 @@
1746
</target>
1847

1948
<target name="compile">
20-
<javac srcdir="${src.java.dir}" destdir="${build.dir}" debug="on" includeantruntime="false" source="1.6" target="1.6" />
49+
<javac srcdir="${src.java.dir}" destdir="${build.classes.dir}" debug="on" includeantruntime="false" source="1.6" target="1.6" />
50+
</target>
51+
52+
<!--
53+
Now for the compile classpaths
54+
-->
55+
56+
<path id="test.compile.classpath">
57+
<fileset dir="${lib.test.dir}" includes="**/*.jar" />
58+
<pathelement path="${build.classes.dir}/" />
59+
</path>
60+
61+
<!--
62+
Now for the test classpath
63+
-->
64+
<path id="test.classpath">
65+
<fileset dir="${lib.test.dir}" includes="**/*.jar" />
66+
<fileset dir="${build.test.classes.dir}">
67+
<include name="**/*.class" />
68+
<include name="**/*.properties" />
69+
</fileset>
70+
</path>
71+
72+
<path id="cobertura.classpath">
73+
<fileset dir="${lib.test.dir}" includes="**/*.jar" />
74+
</path>
75+
76+
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
77+
78+
<!--
79+
Compile all of the test cases
80+
-->
81+
<target name="compile-test" depends="compile" description="[cobertura-build] Compile all of the test code sources">
82+
<javac srcdir="${test.java.dir}" destdir="${build.test.classes.dir}" debug="on" includeantruntime="false">
83+
<classpath path="${build.classes.dir}" />
84+
<classpath refid="test.classpath" />
85+
</javac>
86+
87+
<copy todir="${build.test.classes.dir}">
88+
<fileset dir="${test.java.dir}">
89+
<include name="**/*.properties" />
90+
</fileset>
91+
</copy>
92+
</target>
93+
94+
<!--
95+
96+
-->
97+
<target name="cobertura" depends="compile-test" description="[cobertura-build] Run the junit tests, compile the cobertura reports">
98+
<delete file="cobertura.ser" />
99+
100+
<cobertura-instrument todir="${cobertura.instrumented.dir}">
101+
<includeClasses regex=".*" />
102+
<excludeClasses regex="org.apache.log4j.*" />
103+
<excludeClasses regex=".*\.Test.*" />
104+
105+
<instrumentationClasspath>
106+
<pathelement location="${build.classes.dir}" />
107+
</instrumentationClasspath>
108+
</cobertura-instrument>
109+
110+
<junit fork="yes" failureProperty="test.failed" printsummary="true" showoutput="true">
111+
<!--
112+
Specify the name of the coverage data file to use.
113+
The value specified below is the default.
114+
-->
115+
<sysproperty key="net.sourceforge.cobertura.datafile" file="${basedir}/cobertura.ser" />
116+
117+
<!--
118+
Note the classpath order: instrumented classes are before the
119+
original (uninstrumented) classes. This is important.
120+
-->
121+
<classpath location="${cobertura.instrumented.dir}" />
122+
<classpath location="${build.classes.dir}" />
123+
124+
<classpath location="${build.test.classes.dir}" />
125+
126+
<!--
127+
The instrumented classes reference classes used by the
128+
Cobertura runtime, so Cobertura and its dependencies
129+
must be on your classpath.
130+
-->
131+
<classpath refid="cobertura.classpath" />
132+
133+
<formatter type="xml" />
134+
<batchtest todir="${junit.reports.xml.dir}" unless="testcase">
135+
<fileset dir="${test.java.dir}">
136+
<include name="${junit.test.pattern}" />
137+
</fileset>
138+
</batchtest>
139+
</junit>
140+
141+
<junitreport todir="${junit.reports.xml.dir}" >
142+
<fileset dir="${junit.reports.xml.dir}">
143+
<include name="TEST-*.xml"/>
144+
</fileset>
145+
<report format="frames" todir="${junit.reports.html.dir}"/>
146+
</junitreport>
147+
<!-- Now generate the report -->
148+
<cobertura-report format="html" destdir="${cobertura.reports.html.dir}" srcdir="${src.java.dir}" />
149+
<cobertura-report format="xml" destdir="${cobertura.reports.xml.dir}" srcdir="${src.java.dir}" />
150+
151+
<fail if="${test.failed}" message="JUnit Tests Failed!!" />
21152
</target>
22153

23-
<target name="dist" depends="clean,init,compile" description="build the distributable jar file">
154+
<target name="dist" depends="clean,init,compile,cobertura" description="build the distributable jar file">
24155
<jar destfile="dist/${ant.project.name}.jar">
25-
<fileset dir="${build.dir}">
156+
<fileset dir="${build.classes.dir}">
26157
<include name="**/*.*"/>
27158
</fileset>
28159
</jar>

lib/test/asm-5.0.1.jar

52 KB
Binary file not shown.

lib/test/asm-analysis-5.0.1.jar

20 KB
Binary file not shown.

lib/test/asm-commons-5.0.1.jar

40.7 KB
Binary file not shown.

lib/test/asm-tree-5.0.1.jar

28.4 KB
Binary file not shown.

lib/test/asm-util-5.0.1.jar

42.3 KB
Binary file not shown.

lib/test/cobertura-2.1.1.jar

551 KB
Binary file not shown.

lib/test/commons-lang3-3.3.2.jar

403 KB
Binary file not shown.

0 commit comments

Comments
 (0)