<project default="test" basedir=".">
	<import file="build-woproject.xml" />

	<target name="build-project" >
		<antcall target="build.${project.type}" />
	</target>

	<target name="framework-init" if="isFramework">
		<property name="appextension" value="framework" />
	</target>

	<target name="application-init" unless="isFramework">
		<property name="appextension" value="woa" />
	</target>

	<target name="setup-test.properties" description="--> setup unit test properties">
		<property name="src.tests" value="Tests" />
		<property name="reports.tests" value="Reports" />

		<condition property="isFramework">
			<equals arg1="${project.type}" arg2="framework" casesensitive="no" trim="yes" />
		</condition>
	</target>

	<target name="test-init" depends="setup-test.properties,framework-init,application-init,init.build" />

	<target name="test-compile" depends="test-init,init.woproject,build-project">
		<wopath id="test.classpath">
			<frameworks root="ProjectLocal" embed="false" eclipse="true" />
			<frameworks root="External" embed="false" eclipse="true" />
			<frameworks root="Local" embed="false" eclipse="true" />
			<frameworks root="User" embed="false" eclipse="true" />
			<frameworks root="System" embed="false" eclipse="true" />
			<frameworks root="Network" embed="false" eclipse="true" />
			<fileset dir="Libraries">
				<include name="*.jar" />
			</fileset>
			<fileset dir="${wo.extensions}">
				<include name="*.jar" />
			</fileset>
			<pathelement location="bin" />
			<pathelement location="." />
		</wopath>
		
		<mkdir dir="bin" />
		<wocompile srcdir="${src.tests}" destdir="bin" source="1.5" target="1.5" debug="true">
			<classpath refid="test.classpath" />
		</wocompile>
	</target>

	<target name="test" depends="test-compile">
		<mkdir dir="${reports.tests}" />
		<wounit printsummary="yes" haltonfailure="yes" showoutput="yes" dir="${dest.dir}/${project.name}.${appextension}">
			<classpath refid="test.classpath" />
			<formatter type="xml" />
			<batchtest fork="yes" todir="${reports.tests}">
				<fileset dir="${src.tests}">
					<include name="**/*Tests.java" />
					<exclude name="**/*TestSuite.java" />
					<exclude name="**/AllTests.java" />
				</fileset>
			</batchtest>
			<sysproperty key="user.name" value="testing" />
		</wounit>
	</target>
</project>
