Running QUnit tests with Jenkins and Apache Ant?

前端 未结 4 1252
离开以前
离开以前 2020-12-24 09:52

Is it possible to execute my QUnit (javascript) unit tests from Jenkins? My build script is Apache Ant. Would Jenkins execute this as a separate Build Step, or would I need

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 10:51

    So, I have finally managed to figure this out.

    Here's my end-to-end implementation:

    1. Install PhantomJS (http://phantomjs.org/) - I installed this in my build/tools folder

    2. Install the PhantomJS QUnit Runner script (https://gist.github.com/1588423) - also installed this in my build/tools folder

    3. Added the following target to my build.xml file:

        
          
          
          
            
            
            
            
          
        
    
    1. Under my Jenkins project config, I now invoke Ant with "minify qunit"

    2. I point Jenkins to the JUnit-style output XML file

    And, here is the workflow:

    1. Check changes into my repo
    2. Jenkins will poll GitHub for changes
    3. If there are any changes, Jenkins will pull down
    4. Ant will be invoked, doing the build, then running my unit tests
    5. The test results will be published in a JUnit-like XML format
    6. Jenkins will analyse this output file. If no tests failed, the build will be marked as "Success". If any tests failed, the build will be marked as "Unstable"
    7. Jenkins will deploy the web changes
    8. Jenkins will cleanup the work-area

    PS: At the moment, you have to manually delete the JUnit-type XML output file. I will fix this later.

    PS: Download the customized qunit.js (https://gist.github.com/2488794)

提交回复
热议问题