Hi,
I try to use FlexUnit 4 to test an air application. I use Maven antrun plugin to compile and run test
code since flex-mojos do not support FlexUnit 4 yet.
My antrun plugin is as follows,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>flexunit4-test-compile</id>
<phase>test-compile</phase>
<configuration>
<tasks>
<!-- You can set this directly so mxmlc will work correctly, or set FLEX_HOME as an environment variable and use as below -->
<!--property name="FLEX_HOME" location="${env.FLEX_HOME}"/-->
<property name="FLEX_HOME" value="${flex.home}"/>
<taskdef resource="flexTasks.tasks"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpathref="maven.compile.classpath"/>
<!-- Compile TestRunner.mxml as a SWF -->
<mxmlc file="${project.build.testSourceDirectory}/TestRunner.mxml"
output="${project.build.testOutputDirectory}/TestRunner.swf">
<source-path path-element="${project.build.sourceDirectory}"/>
<source-path path-element="${project.build.testSourceDirectory}"/>
<load-config filename="${FLEX_HOME}/frameworks/air-config.xml"/>
<compiler.library-path dir="${basedir}/target/dependency" append="true">
<include name="*.*"/>
</compiler.library-path>
<compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
<compiler.headless-server>true</compiler.headless-server>
</mxmlc>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>flexunit4-test-run</id>
<phase>test</phase>
<configuration>
<tasks>
<!-- Execute TestRunner.swf as FlexUnit tests and publish reports -->
<!--
Flex-Mojos will update the FlashPlayer trusted cache for you automagically so you don't have to have flexunit do so.
Also haltonfailure should be marked true to keep with the convention in Maven that the build fails if tests fail.
-->
<taskdef resource="flexUnitTasks.tasks"/>
<exec executable="${flex.home}/bin/adl" failonerror="false" osfamily="unix">
<arg value="${project.build.testOutputDirectory}/TestRunner-app.xml"/>
<arg value="--"/>
<arg value="${project.build.testOutputDirectory}"/>
</exec>
<exec executable="${flex.home}/bin/adl.exe" failonerror="false" osfamily="windows">
<arg value="${project.build.testOutputDirectory}/TestRunner-app.xml"/>
<arg value="--"/>
<arg value="${project.build.testOutputDirectory}"/>
</exec>
<!--flexunit swf="${project.build.testOutputDirectory}/TestRunner.swf"
toDir="${project.build.directory}/surefire-reports"
haltonfailure="true"
verbose="true"
localTrusted="false"/-->
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- You will need to manually install all of the artifacts below in your local Maven repository or shared repository if you have one -->
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>flexTasks</artifactId>
<version>${flex-sdk.version}</version>
</dependency>
<dependency>
<groupId>org.flexunit</groupId>
<artifactId>anttasks</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
</plugin>
TestRunner.swf is built at target/test-class and I also have TestRunner-app.xml in the same directory where I have
<content>TestRunner</content>
The problem is that when I try to run a test, I keep getting the following error
[exec] initial content not found
I really appreciate if someone could shred some light on this problem.
Thanks,
John