Unittests not running

tomnagelgast's Avatar

tomnagelgast

20 Nov, 2013 10:52 AM

Hey,

I've got the build running, but whenever I call the test task, I get 'Skipping tests since no tests exist' as a result. There's one test file with one simple test in it and I can run it from Flash Builder, but it doesn't seem to work on the Jenkins system. Any ideas how to make it notice the tests?

I included my build file for reference.

PS: How do I get FlexUnit to run as a Maven repo (i.e. calling it with org.adobe etc)? I'm new to it and the documentation is somewhat confusing.

Thanks!

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath group: 'org.gradlefx', name: 'gradlefx', version: '0.7'
    }
}
apply plugin: 'gradlefx'

mainClass = 'BuildTest.as'

srcDirs = ['src']
testDirs = ['src/tests']

type = 'mobile'

dependencies {
    merged files('lib/starling/bin/starling.swc')
    merged files('lib/output/feathers.swc')
    
    test files('/sdks/FLEXUNITSDK/flexunit-4.1.0-8-flex_4.1.0.16076.swc')
    test files('/sdks/FLEXUNITSDK/flexUnitTasks-4.1.0-8.jar')
    test files('/sdks/FLEXUNITSDK/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc')
}

air {
    keystore 'Certificate.p12'
    storepass '*****'
    applicationDescriptor 'src/BuildTest-app.xml'
}
  1. Support Staff 1 Posted by Yennick Trevels on 20 Nov, 2013 11:28 AM

    Yennick Trevels's Avatar

    Does your test class' name end with "Test.as"? Because that's the convention we use to recognize tests in the test directory. You can modify this behaviour as follows:

    flexUnit {
            includes = ['**/Test*.as'] //will include all actionscript classes which start with 'Test'
            excludes = ['**/IntegrationTest*.as']
    }
    

    Regarding the Maven repo question, do you mean how to specify the FlexUnit dependencies when they're located in a Maven repository? If so, then you can do it like this:

    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'
    }
    
  2. 2 Posted by tomnagelgast on 20 Nov, 2013 11:35 AM

    tomnagelgast's Avatar

    Yes, it does.

    The Maven question was about how to actually setup the repo, but that's less related to GradleFX

  3. Support Staff 3 Posted by Yennick Trevels on 20 Nov, 2013 12:17 PM

    Yennick Trevels's Avatar

    Can you show me your folder structure and where the test class is located?

    As for setting up a maven repo, this is indeed not a GradleFx question. But to get you started, you can use repository servers such as Nexus or Artifactory which you install on your infrastructure. Then you upload your FlexUnit swc's to it by providing it a group name (such as 'com.adobe.flexunit'), an artifactId (such as 'flexunit') and a version (such as '4.1.0-8').
    Installation of such a repository and uploading the artifacts differs per repo server, so you best have a look at their documentation.

  4. Support Staff 4 Posted by Maxime Cowez on 20 Nov, 2013 12:23 PM

    Maxime Cowez's Avatar

    I'm not sure what happens when the test source files are in the same source tree as the other source files (like in your setup). Either way it would be a good idea to separate them. The GradleFx defaults are src/main/actionscript and src/test/actionscript.

    About the Maven question you'll have to host your own artifact repository and deploy the swcs there, since the flexunit artifacts are not on any public repo (unless they are now under the Apache Flex umbrella). Have a look at Artifactory or Sonatype Nexus.

  5. 5 Posted by tomnagelgast on 20 Nov, 2013 01:04 PM

    tomnagelgast's Avatar

    Ok, so I tried setting up the folder structure according to the defaults, but now I'm getting errors about the Main file, (translated) 'a found file in a sourcepath must be the same package structure '' as the package definition 'main.actionscript'

    My folder structure now is:
    src
    --main.actionscript-->Main files (BuildTest.as and BuildTest-app.xml), also the FlexUnit xmls and .as

    --test.actionscript-->BuildTestTest.as

    --nl.company.BuildTest-->core (and more engine stuff)

  6. Support Staff 6 Posted by Yennick Trevels on 20 Nov, 2013 01:54 PM

    Yennick Trevels's Avatar

    Looks like your package definition in the BuildTest.as file isn't correct. If your BuildTest.as file is located right under /main/actionscript, then it should have the following package definition:

    package {
    }
    

    So it should define that it's located in the default package ('main.actionscript' isn't considered as a package, but as a source folder)

  7. 7 Posted by tomnagelgast on 21 Nov, 2013 09:31 AM

    tomnagelgast's Avatar

    I seperated the src and test folders and now it's working! Because src was my only source folder it saw the test subfolder as a package and that probably screwed with the plugin.

    Thanks so much for the help!

    One final question, in the -app.xml (2nd line), in my FB it wants to use Air 3.8 and on Gradle it wants to use 3.1. Any way to make this the same on both ends?

  8. Support Staff 8 Posted by Yennick Trevels on 21 Nov, 2013 09:39 AM

    Yennick Trevels's Avatar

    Is FB using the same Flex/AIR SDK as the one you defined in the FLEX_HOME environment variable (I assume you're using this method to define the sdk in GradleFx)? If not, then you have to align those by making FB point to the correct sdk.

  9. 9 Posted by tomnagelgast on 21 Nov, 2013 04:09 PM

    tomnagelgast's Avatar

    Ah, the Flex SDK from Adobe only includes an older version of AIR, I merged in the current version and now it's working fine (weird that they do that though).

    Next issue is the last mismatch between the develop environment and the build server. When building in FB, it copies the app.xml to the bin-debug folder and uses that to find the swf that's made there. GradleFX doesn't copy the xml to the build folder, and I can't find the swf when used from the source folder. Is there a setting I can use to have it copied or another way to make the xml work on both machines?

  10. Support Staff 10 Posted by Yennick Trevels on 21 Nov, 2013 08:33 PM

    Yennick Trevels's Avatar

    Here's a solution that should work. Basically we're doing the same as FB, right before executing the 'package' task in GradleFx we copy the application descriptor to the build directory and change the 'content' tag so it satisfies GradleFx's requirements.

    tasks.package.doFirst {
        def applicationDescriptorXml = new XmlParser().parse file('src/main/actionscript/air-single-project.xml').absolutePath
        applicationDescriptorXml.initialWindow.content[0].value = 'build/' + applicationDescriptorXml.initialWindow.content.text()
        project.file(buildDir.name + '/' + 'air-single-project.xml').withWriter { out ->
            XmlUtil.serialize applicationDescriptorXml, out
        }
    }
    
  11. Support Staff 11 Posted by Maxime Cowez on 23 Nov, 2013 02:01 PM

    Maxime Cowez's Avatar

    "weird that they do that though"

    Adobe stopped development of the Flex SDK at version 4.6. Hence the targeted AIR version is the one that was available at that time. If you want a more recent version of AIR packaged with the Flex SDK by default, you'll have to use the latest Apache Flex SDK. Transitioning from Adobe Flex to Apache Flex is a simple matter of switching SDK's; Apache Flex is fully backwards compatible with Adobe Flex.

  12. 12 Posted by tomnagelgast on 25 Nov, 2013 12:56 PM

    tomnagelgast's Avatar

    Yennick: Yes, that looks like what I need. Though it doesn't look like it's working on a mobile project. I changed it to run on packageSimulatorMobile, but then I get an error that it can't find XmlUtil on the task.

    Maxime: Thanks for the tip, I switched them out, works great!

  13. Support Staff 13 Posted by Yennick Trevels on 25 Nov, 2013 01:09 PM

    Yennick Trevels's Avatar

    Yeh, I forgot to add the import statements :)
    Here they are:

    import groovy.xml.XmlUtil
    import groovy.util.XmlParser
    
  14. 14 Posted by tomnagelgast on 27 Nov, 2013 10:55 AM

    tomnagelgast's Avatar

    Yes! It's working perfectly now, great stuff.

    Thanks a lot for all the help, love the fast responses.

  15. Yennick Trevels closed this discussion on 27 Nov, 2013 11:09 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac