GradleFx supports automatically running tests written with FlexUnit 4.1.
First you need to specify the FlexUnit dependencies. You can download the required FlexUnit libraries from their site and then deploy them on your repository (recommended) or use file-based dependencies. Once you’ve done that you have to define them as dependencies in your build file.
When you have deployed the artifacts on your own repository:
dependencies {
test group: 'org.flexunit', name: 'flexunit-tasks', version: '4.1.0-8', ext: 'swc'
test group: 'org.flexunit', name: 'flexunit', version: '4.1.0-8', ext: 'swc'
test group: 'org.flexunit', name: 'flexunit-cilistener', version: '4.1.0-8', ext: 'swc'
}
When you have FlexUnit installed on your machine:
def flexunitHome = System.getenv()['FLEXUNIT_HOME'] //FLEXUNIT_HOME is an environment variable referencing the FlexUnit install location
dependencies {
test files("${flexunitHome}/flexunit-4.1.0-8-flex_4.1.0.16076.swc",
"${flexunitHome}/flexUnitTasks-4.1.0-8.jar",
"${flexunitHome}/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc")
}
Then you’ll need to specify the location of the Flash Player executable. GradleFx uses the FLASH_PLAYER_EXE environment variable by convention which should contain the path to the executable. If you don’t want to use this environment variable you can override this with the ‘flexunit.command’ property. You can download the executable from here (these links may get out of date, look for the Flash Player standalone/projector builds on the Adobe site):
And that’s basically it in terms of setup when you follow the following conventions:
GradleFx will by convention execute all the *Test.as classes in the test source directory when running the tests.
You can run the FlexUnit tests by executing the “gradle test” command on the command-line.
You can change these directories by specifying the following properties like this:
testDirs = ['src/testflex']
testResourceDirs = ['src/testresources']
You can include or exclude test classes which are being run by specifying a pattern to some GradleFx properties. To specify the includes you can use the flexUnit.includes property:
flexUnit {
includes = ['**/Test*.as'] //will include all actionscript classes which start with 'Test'
}
To specify the excludes you can use the flexUnit.excludes property:
flexUnit {
excludes = ['**/*IntegrationTest.as']
}
There are a lot more properties available on flexUnit.*, all these can be found on the properties description page.