Currently flexmojos supports the following frameworks:
Pom dependency
Flexmojos 3.4 and newer versions
On Flexmojos 3.4 the unittest-support dependency is no longer required and actually MUST BE REMOVED from the pom. Now, you only need to add the unit test framework to your dependencies. This better mirrors how Java/Surefire work. More details on dependencies GAV here.
Flexmojos 3.3 and previous versions
To activate unit test support, simply add the following dependency to your POM:
Code Block | ||||
---|---|---|---|---|
| ||||
<dependency>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-unittest-support</artifactId>
<version>${flexmojos.version}</version>
<type>swc</type>
<scope>test</scope>
</dependency>
|
Flexmojos requires FlashPlayer to run unit tests.
We recommend using the debug version of the Standalone player (also known as "Projector"). It can be found here.
Direct links:
- Windows version
- Mac version
- Linux version
Note: These links may get out to date. Check Adobe site to be sure.
Once installed, make sure it is available on PATH.
OS | Expected executable on PATH | Tips |
---|---|---|
Windows | FlashPlayer.exe |
|
Mac | Flash Player |
|
*nix | flashplayer |
|
Note 2: On Mac OS, add /${flashplayer.dir}/Flash Player.app/Contents/MacOS/
folder to PATH.
Note: After updating PATH you probably need to restart your CI environment (Bamboo, Hudson etc.)
Anchor | ||||
---|---|---|---|---|
|
Alternatives for those who don't want to include flashplayer on PATH
Flexmojos 4.x
The Maven property name was changed from "flashPlayer.command" to "flex.flashPlayer.command". It is a Maven best practice to set system specific properties like this in your settings.xml file rather than your project pom.xml:
Code Block | ||||
---|---|---|---|---|
| ||||
<properties>
<!-- Point to standalone flashplayer -->
<flex.flashPlayer.command>/opt/flash_standalone/flashplayer</flex.flashPlayer.command>
</properties>
|
After Flexmojos 3.3
On Flexmojos 3.3 testing support was modularized and created a new component to launch tests. But Maven is no longer able to inject flashPlayer.command
on it. So if you rely on that (instead of add to path witch is the recommended approach) you must do this:
Code Block | ||||
---|---|---|---|---|
| ||||
<build>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<version>3.3.0</version>
<artifactId>flexmojos-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<testRunner>
<launcher>
<flashplayerCommand>${flashPlayer.command}</flashplayerCommand>
</launcher>
</testRunner>
</configuration>
</plugin>
</plugins>
</build>
|
Once that is on pom flashPlayer.command
argument will work again.
Before flexmojos 3.3
Add the following argument on command line -DflashPlayer.command=${flashplayer executable}
Anchor | ||||
---|---|---|---|---|
|
Tips for flexmojos + linux + continuous integration
If you are running flexmojos on a headless Linux server you have 2 options:
- provide a GUI environment for flashplayer
- provide the tools that flexmojos needs to create its own environment
- install Xvfb and xvfb-run
- install xvfb-run if not installed with Xvfb server
- install flashplayer dependencies. On Ubuntu 8.04 server it was necessary to install: libxt6, libgtk2.0-0 and libnss3-1d. The names may vary, depending on the Linux distribution.
- when using non-root, be aware that the user needs permission to write to 2 folders: ~/.adobe and /tmp/.X11-unix
- make sure /etc/X11/xserver/SecurityPolicy exists! If does't copy it from /usr/share/doc/examples/SecurityPolicy or download this one.
- enable flash debugging (take a look here)
- to run adl on 64-bits linux you will need to do some extra work, check the steps here
Some extra tips from users:
- add HOME (=/usr/share/tomcat6) variable in /etc/init.d/tomcat6
- change ~/.Xauthority file ownership and pemission (so that tomcat user can write to it, and owns it)
- on 64-bit machines, make sure you have the 32 -bit versions of curl and nss installed
You can have your build fail with the following error:
No Format [INFO] [flexmojos:test-run {execution: default-test-run}] [INFO] Flexmojos 3.7.1 [INFO] Apache License - Version 2.0 (NO WARRANTY) - See COPYRIGHT file [INFO] Running tests /home/user/project/target/test-classes/TestRunner.swf [WARNING] [LAUNCHER] Using regular flashplayer tests [INFO] ------------------------------------------------------------------------ [INFO] Tests run: 0, Failures: 0, Errors: 0, Time Elapsed: 0 sec [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Read timed out /home/user/project/target/test-classes/TestRunner.swf
This might be caused by a unit test that gives a runtime error (In my case because of 'type coercion failed'). If you have this on your headless CI server, try running the tests manually on your development machine to see if an error dialog pops up.
If you have any other extra tips, please edit this page.
Anchor | ||||
---|---|---|---|---|
|
What to do if there is no way to get tests working properly?
Java/Flex integration to run test is solid, but not bullet proof, so there are an infinite number of reasons to it not work as it should. Usually the problem can be in 3 places:
- Flexmojos
- User environment
- User tests
Usually, it is not on Flexmojos. This is a very well tested on an health environment, using some predictable tests. So the most probable places to be causing problems are user environment and/or tests.
The fastest way to know if the environment is correctly setup is running the tests used by Flexmojos during integration tests. They can be found here:
Framework | SVN Url |
---|---|
Flexunit | |
Flexunit 4 | |
asunit | |
fluint | |
funit | |
advanced flex |
It is necessary to edit the pom and replace %{flexmojos.version
} with the desired Flexmojos version.
If the test from Flexmojos works, mean you environment is OK! and Flexmojos is double OK!
Most common problems on user tests are:
- Try to replace the template with a broken one;
If you know any other common problem, please edit this page.Download the Windows Flash Player 10.2 Projector content debugger
Anchor | ||||
---|---|---|---|---|
|
Using Flash Player Debugger on Mac to run FlexUnit Tests
Flexmojos expects to find an executable file with the name "Flash Player" inside of the Flash Player folder "Contents/MacOS", but the name of the executable file inside debug version is: Flash Player Debugger
To solve this problem, you have to set a symbolic link.
With the following commands, you can install and set symbolic link:
No Format |
---|
unzip flashplayer_10_sa_debug.app.zip
sudo cp -r Flash\ Player\ Debugger.app /Applications/
cd /Applications/Flash\ Player\ Debugger.app/Contents/MacOS
sudo ln -s Flash\ Player\ Debugger Flash\ Player
|
Anchor | ||||
---|---|---|---|---|
|
Running FlexUnits test using m2e Eclipse Plugin on Mac
Applications with UI (Eclipse or IntelliJ) of MAC haven't access to extended environment variable PATH.
To solve this problem, you have to set the flashPlayer.command in Eclipse so that Maven can launch the Flash Player.
1.Solution: Set the Enviroment Variable in Maven Lauch Configuration of Eclipse.
Eclipse -> Run -> Run Configurations -> Select the Maven Build in the left column -> Environment -> New
Set following values:
Variable: PATH
Value: /Applications/Flash\ Player.app/Contents/MacOS (if the Flash Player is located below "/Applications")
And select the RadioButton: Append environment to native environment
Click "OK" to finish.
2.Solution: Add location of the Flash Player as property to your pom.xml
Code Block | ||||
---|---|---|---|---|
| ||||
<properties>
<flashPlayer.command>/Applications/Flash Player Debugger.app/Contents/MacOS/Flash Player</flashPlayer.command>
</properties>
|
Tip: If you use Maven profiles, you can use the second solution to target different player versions or different environments (e.g. development evironment, CI)
Code Block | ||||
---|---|---|---|---|
| ||||
<profile>
<id>dev</id>
<properties>
<flashPlayer.command>/Applications/Flash Player Debugger.app/Contents/MacOS/Flash Player<</flashPlayer.command>
</properties>
</profile>
<profile>
<id>CI</id>
<properties>
<flashPlayer.command>/DEVEL/flex/flex_sdk_4.1/runtimes/player/10.1/lnx/flashplayerdebugger</flashPlayer.command>
</properties>
</profile>
|