forked from SoftwareAG/sagdevops-ci-assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildTest.xml
150 lines (122 loc) · 5.58 KB
/
buildTest.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?xml version="1.0"?>
<project name="test" default="startTest" basedir=".">
<property name="testSuitePackagesPath" value="${isTestDir}"/>
<path id="junitClasspath">
<fileset dir="${SAGHome}/common/lib/ext" includes="enttoolkit.jar" />
<fileset dir="${SAGHome}/common/lib" includes="**/gf.javax.mail.jar" />
<fileset dir="${SAGHome}/common/lib" includes="wm-isclient.jar" />
<fileset dir="${SAGHome}/IntegrationServer/lib" includes="wm-isserver.jar" />
<fileset dir="./lib" includes="httpunit.jar" />
<fileset dir="./lib" includes="junit*.jar" />
<fileset dir="./lib" includes="xmlunit*.jar" />
<fileset dir="./lib" includes="serviceInterceptor.jar" />
<fileset dir="./lib" includes="serviceMockClient.jar" />
</path>
<target name="startTest" depends="jenkinsCheck">
<var name="failedTestList" value=""/>
<!-- interate over the test project and triiger all xml tests in the setup folder -->
<for param="testProject" keepgoing="true" trim="true">
<path>
<dirset dir="${testSuitePackagesPath}" includes="*" excludes=".*,replicate" />
</path>
<sequential>
<trycatch reference="exception_ref">
<try>
<echo message="@{testProject}"/>
<antcall target="junitTestAndReportXML">
<param name="testPackageName" value="@{testProject}" />
</antcall>
<!--antcall target="junitTestAndReportJava">
<param name="testPackageName" value="${testSuitePackagesPath}/@{testProject}" />
</antcall-->
</try>
<catch>
<echo message="JUnit test for package '@{testProject}' failed" />
<var name="failedTestList" value="${failedTestList}'@{packageName}', " />
<property name="testFail" refid="exception_ref" />
</catch>
</trycatch>
</sequential>
</for>
<if>
<not>
<equals arg1="${failedTestList}" arg2="" trim="true" />
</not>
<then>
<fail unless="isReportingToJenkins" message="At least one test failed. Failed packages: ${failedTestList}" />
</then>
<else>
<echo message="All JUnit Tests passed."/>
</else>
</if>
</target>
<target name="junitInitTest">
<echo message="Init JUnit tests for package ${testPackageName}" />
<property name="testPackageReportsDir" value="${testPackageName}/resources/reports" />
</target>
<target name="junitCleanUp">
<delete dir="${testPackageReportsDir}" />
</target>
<!--execute only if the XML Test directory exists in the test package -->
<target name="junitTestAndReportXML" depends="junitInitTest,junitCleanUp">
<echo message="Starting JUnit tests for package '${testPackageName}'"/>
<mkdir dir="${testPackageReportsDir}" />
<property name="resourcesFolder" value="${testPackageName}/resources" />
<for param="testSetupFile" keepgoing="true">
<path>
<!--fileset dir="${testPackageXmlDir}" includes="*.xml" /-->
<fileset dir="${testPackageName}" includes="**/setup/*.xml" />
</path>
<sequential>
<basename property="fileBasename" file="@{testSetupFile}" suffix=".xml" />
<echo message="Running JUnit test '@{testSetupFile}'"/>
<junit printsummary="yes" haltonfailure="no" fork="true" failureproperty="test:failure" showoutput="true" dir="${testPackageName}">
<jvmarg value="-DwebMethods.integrationServer.name=${testISHost}" />
<jvmarg value="-DwebMethods.integrationServer.port=${testISPort}" />
<jvmarg value="-DwebMethods.integrationServer.userid=${testISUsername}" />
<jvmarg value="-DwebMethods.integrationServer.password=${testISPassword}" />
<jvmarg value="-DwebMethods.test.setup.filename=@{testSetupFile}" />
<!--jvmarg value="-Dresources.folder=${resourcesFolder}" /-->
<classpath>
<path refid="junitClasspath" />
</classpath>
<formatter type="xml" />
<test name="com.wm.ps.test.WmTestSuite" outfile="TEST-${fileBasename}" haltonerror="false" haltonfailure="false" todir="${testPackageReportsDir}" />
</junit>
<replaceregexp file="${testPackageReportsDir}/TEST-${fileBasename}.xml" match=" name="com.wm.ps.test.WmTestSuite" " replace=" name="com.wm.ps.test.WmTestSuite [${fileBasename}]" " />
<var name="fileBasename" unset="true" />
</sequential>
</for>
<!-- if jenkins report dir is set publicate results there-->
<antcall target="junitCopyResultsToReportsDir">
<param name="current.report.dir" value="${testPackageReportsDir}" />
</antcall>
<!-- create HTML report of the test results -->
<junitreport todir="${testPackageReportsDir}">
<fileset dir="${testPackageReportsDir}">
<include name="TEST-*.xml" />
<exclude name="TESTS-TestSuites.xml" />
</fileset>
<report format="frames" todir="${testPackageReportsDir}/html" />
</junitreport>
<fail if="test:failure">Unit test failure</fail>
</target>
<!-- if jenkins report dir is set publicate results there-->
<target name="junitCopyResultsToReportsDir" depends="jenkinsCheck" if="isReportingToJenkins">
<echo message="Copying JUnit test results to folder '${jenkinsReportDir}'"/>
<copy todir="${jenkinsReportDir}">
<fileset dir="${current.report.dir}">
<include name="*.*" />
<exclude name="TESTS-TestSuites.xml"/>
</fileset>
</copy>
</target>
<!-- will jenkins evaluate the test results -->
<target name="jenkinsCheck" >
<condition property="isReportingToJenkins">
<not>
<equals arg1="${jenkinsReportDir}" arg2="" trim="true"/>
</not>
</condition>
</target>
</project>