Initiating the development of automated testing on a Windows system. As a first step, then everything went quite easily: maven compile applications, compiled tests and run tests.
The first problem faced by, it was a test run on a Linux server without a graphical shell. This influenced the choice of automated testing environment, Hudson has a Xvnc plugin (http://wiki.hudson-ci.org/display/HUDSON/Xvnc+Plugin) which allows you to run vncserver + has a large number of useful plug-ins for the project.
The next problem encountered relate to the project. To cover used flexcover (http://code.google.com/p/flexcover/). In flex-mojos has plug-ins to work with flexcover (flexmojos: flexcover, flexmojos: flexcover-run), but their use was a problem:
- The problem of generation. Cvm file that was used to generate coverage. CVM was empty. Generation cvm place with a modified sdk and compiler, which load from the repository http://flex-mojos.googlecode.com/svn/trunk/repository/
In the pom.xml file for this meet record
<repository>
<id>flexcover</id>
<url>http://flex-mojos.googlecode.com/svn/trunk/repository</url>
</repository>
<plugin>
....
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>3.0.1.1092-flexcover_0.61</version>
<type>pom</type>
</dependency>
</dependencies>
....
</plugin>
<dependencies>
.....
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>3.0.1.1092-flexcover_0.61</version>
<type>pom</type>
</dependency>
......
<dependencies>
Problem resolved creating a local retrofit sdk and connect its config in the pom.xml with the following entries
<configuration>
....
<configFile>/path/to/the/modifcation_sdk/framework/flex-config.xml</configFile>
....
</configuration>
-The next problem faced by this is that when you start the task flexmojos: flexcover: run TestRunner.mxml not send command CoverageViwer CoverageAgent.exit (). Flexmojos uses peculiar TestRunner. The problem solved by writing their own TestRunner.mxml. Our TestRunner work only with Flexunit 0.85, 0,95. Above compatibility problem with Flexunit 4 still working.
Our TestRunner:
<pre><?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
creationComplete="onCreationComplete()">
<!--can't use velocity, got:
java.io.InvalidClassException: org.apache.velocity.runtime.parser.node.ASTprocess; class invalid for deserialization-->
<mx:Script>
<![CDATA[
import flexunit.junit.JUnitTestRunner;
import flexunit.framework.TestSuite;
import com.allurent.coverage.runtime.CoverageManager;
import mx.controls.Alert;
$imports
[Bindable]
private var runner : JUnitTestRunner;
private function onCreationComplete() : void {
status.text = "Complete";
runner = new JUnitTestRunner();
runner.port = $port;
runner.run( createSuite(), onTestComplete );
}
private function onTestComplete() : void {
var waitTimer:Timer = new Timer(2000,1);
waitTimer.addEventListener(TimerEvent.TIMER,closeDown);
waitTimer.start();
}
private function createSuite() : TestSuite {
var testSuite : TestSuite = new TestSuite();
testSuite.addTestSuite( Yor test name );
return testSuite;
}
private function closeDown(event:TimerEvent):void
{
callLater(exitCoverageManager);
}
/** Close the Covereage Manager */
private function exitCoverageManager():void
{
CoverageManager.exit();
}
]]>
</mx:Script>
<mx:Label id="status" />
</mx:Application></pre>
What would TestRunner worked in our application need to connect it to the maven, and load flex-junit in project
<plugin>
.....
<testRunnerTemplate>/path/to/the/TestRunner</testRunnerTemplate>
.....
</plugin>
</dependencies>
......
<dependency>
<groupId>flexunit.junit</groupId>
<artifactId>flexunit-optional</artifactId>
<version>0.85</version>
<type>swc</type>
<scope>test</scope>
</dependency>
.....
</dependencies>
P.S. Need to use Flashplayer version 10 and CoverageViwer version 0.51. What would work with CoverageViwer version 0.81 to run the build as follows:
<profile>
<id>flexcover</id>
<properties>
<flex.sdk.version>3.2.0.3794-flexcover_0.81</flex.sdk.version>
</properties>
<build>
<plugins>
<plugin>
<!-- To run this plugin type mvn -Pflexcover in the root of your checkout. -->
<groupId>info.flex-mojos</groupId>
<artifactId>flex-compiler-mojo</artifactId>
<version>${flex-mojos.version}</version>
<configuration>
<runtimeLocales>
<locale>en_US</locale>
</runtimeLocales>
<configFile>C:/Tools/flexcover/flexcover-sdk-3.0.0/frameworks/flex-config.xml</configFile>
<!-- Logan's config --> <!--<configFile>/Users/logan/projects/flexcover_sdk-0.81/frameworks/flex-config.xml</configFile>-->
</configuration>
</plugin>
</plugins>
</build>
</profile>
The locales stuff is optional.
Run with -P flexcover once to get all your .cvms built and the instrumented swcs in your local repo, then we manually open CoverageViewer and load all of our cvms, then we run it again with -Pflexcover to run the tests and capture the output.But none of that automation who want to see!
-The last task is converting cvr in a format understandable for the Hudson. Has been based upon article (http://www.brianlegros.com/blog/2009/10/19/converting-a-flexcover-cvr-to-cobertura-xml-report/) and maven plagin (http://mojo. codehaus.org / xml-maven-plugin / transformation.html)
The value in the xsl file does not convey as explicitly specified in the examples
<xsl:param name="timestamp" select="'MM/dd/yyyy'"/>
<xsl:param name="version" select="0.61"/>
<xsl:param name="sourcePath" select="'full/paths'" />
I hope this article will help you!
Regerds,
Devteam nordsign.dk