aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test.xml
blob: 107ef5b5a281fa36340f9e3bb4b838b5ecc54a9f (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?xml version="1.0"?>

<project name="Run Vaadin Testbench Tests" basedir="." default="run-and-clean-up">
	<!-- ================================================================== -->
	<!-- Configuration                                                      -->
	<!-- ================================================================== -->
	<!-- Browsers to use for testing -->
	<property name="browsers" value="winxp-ie6,winxp-ie7,winxp-ie8,winxp-firefox36,winxp-safari4,winxp-googlechrome41,winxp-opera1050" />
	
	<!-- Screen shot base directory -->
	<fail unless="com.vaadin.testbench.screenshot.directory" message="The 'com.vaadin.testbench.screenshot.directory' property must be defined." />
	
	<!-- Host running Testbench Hub -->
	<property name="com.vaadin.testbench.tester.host" value="192.168.1.44" />

	<!-- Temporary output directory, created and removed by this script -->
	<property name="test-output-dir" value="../build/test-output" />

	<property name="class-dir" value="${test-output-dir}/classes" />
	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
		<classpath>
			<pathelement location="../build/lib/ant-contrib-1.0b3.jar"/>
		</classpath>
	</taskdef>

	<!-- classpath must include test bench jar and its dependencies -->
	<path id="classpath">
		<fileset dir="${com.vaadin.testbench.lib.dir}" includes="**/*.jar" />
	</path>

	<!-- fileset containing all tests to run -->
	<fileset dir=".." id="html-test-files">
		<include name="src/com/vaadin/tests/**/**.html" />
		<include name="tests/**/**.html" />
		<exclude name="tests/integration-testscripts/**" />
	</fileset>

	<!-- This target converts HTML tests files to java junit tests. One test file for each browser is created. -->
	<target name="create-tests" depends="remove-temp-testclasses" if="server.start.succeeded">
		<fileset id="tests">
			<include />
		</fileset>
		<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />

		<java classname="com.vaadin.testbench.util.TestConverter" classpathref="classpath">
			<arg value="${test-output-dir}" />
			<arg value="${browsers}" />
			<arg line="${testfiles}" />
		</java>
	</target>

	<!-- This target complies the generated java junit tests. -->
	<target name="compile-tests" depends="create-tests">
		<mkdir dir="${class-dir}" />
		<javac srcdir="${test-output-dir}" destdir="${class-dir}" debug="on">
			<classpath>
				<path refid="classpath" />
			</classpath>
		</javac>
	</target>


	<!-- ================================================================== -->
	<!-- Toolkit Server Management                                          -->
	<!-- ================================================================== -->

	<target name="server-start">
		<fail unless="output-dir" message="The 'output-dir' (usually build/result/vaadin-xxx) should be given to test script." />
		<fail unless="package.name" message="The 'package.name' property must be defined." />
		<fail unless="package.filename" message="The 'package.filename' property must be defined." />
		<fail unless="testing.testarea" message="The 'testing.testarea' property must be defined." />

		<echo>Package name: ${package.name}</echo>
		<echo>Package filename: ${package.filename}</echo>
		<echo>Testing area: ${testing.testarea}</echo>

		<exec executable="python" searchpath="true" dir=".." resultproperty="server.start.result">
			<arg value="build/testing/toolkit-server.py" />
			<arg value="start" />
			<arg value="${package.name}" />
			<arg value="${package.filename}" />
			<arg value="${output-dir}" />
			<arg value="${testing.testarea}" />
		</exec>

		<condition property="server.start.succeeded">
			<equals arg1="${server.start.result}" arg2="0" />
		</condition>
	</target>

	<target name="server-stop">
		<exec executable="python" dir=".." searchpath="true" resultproperty="server.stop.result">
			<arg value="build/testing/toolkit-server.py" />
			<arg value="stop" />
		</exec>
	</target>

	<!-- ================================================================== -->
	<!-- Running Tests                                                      -->
	<!-- ================================================================== -->

	<target name="check-parameters">
		<fail unless="com.vaadin.testbench.lib.dir" message="The 'com.vaadin.testbench.lib.dir' property must be defined." />
		<fail unless="com.vaadin.testbench.tester.host" message="The 'com.vaadin.testbench.tester.host' property must be defined." />
		<fail unless="com.vaadin.testbench.deployment.url" message="The 'com.vaadin.testbench.deployment.url' property must be defined." />
	</target>

	<target name="run-tests" depends="compile-tests" if="server.start.succeeded">
		<foreach maxthreads="20" parallel="true" target="execute-tests" param="target">
			<path>
				<fileset dir="${test-output-dir}" includes="**/**.java" />
			</path>
		</foreach>
	</target>

	<!-- This target runs the generated and compiled junit tests -->
	<target name="execute-tests">
		<junit fork="yes" printsummary="withOutAndErr">
			<classpath>
				<path refid="classpath" />
				<pathelement path="${class-dir}" />
			</classpath>

			<jvmarg value="-Dcom.vaadin.testbench.tester.host=${com.vaadin.testbench.tester.host}" />
			<jvmarg value="-Dcom.vaadin.testbench.deployment.url=${com.vaadin.testbench.deployment.url}" />
			<!-- Define where the reference screenshots and diff files are saved -->
			<jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" />
			<jvmarg value="-Djava.awt.headless=true" />

			<!-- true/false system arguments -->
			<jvmarg value="-Dcom.vaadin.testbench.screenshot.softfail=${com.vaadin.testbench.screenshot.softfail}" />
			<jvmarg value="-Dcom.vaadin.testbench.screenshot.reference.debug=${com.vaadin.testbench.screenshot.reference.debug}" />
			<jvmarg value="-Dcom.vaadin.testbench.screenshot.cursor=${com.vaadin.testbench.screenshot.cursor}" />

			<batchtest>
				<filelist dir="${test-output-dir}" files="${target}" />
			</batchtest>
		</junit>

	</target>

	<!-- Remove temporary source and compiled java files -->
	<target name="remove-temp-testclasses">
		<delete failonerror="false">
			<fileset dir="${test-output-dir}">
				<include name="**/**.java" />
				<include name="**/**.class" />
			</fileset>
		</delete>
	</target>

	<!-- Remove old error screenshots -->
	<target name="remove-error-screens">
		<mkdir dir="${com.vaadin.testbench.screenshot.directory}/errors" />
		<delete>
			<fileset dir="${com.vaadin.testbench.screenshot.directory}/errors">
				<include name="**/**.*" />
			</fileset>
		</delete>
	</target>

	<!-- ================================================================== -->
	<!-- Main Targets                                                       -->
	<!-- ================================================================== -->

	<!-- The default target. -->
	<target name="run-and-clean-up"
            depends="check-parameters,remove-error-screens,run-tests,remove-temp-testclasses"
            if="server.start.succeeded">
	</target>

	<!-- Also starts the server. -->
	<target name="test-package" depends="server-start, run-and-clean-up, server-stop">
	</target>

</project>