UIAutomation with code coverage

前端 未结 2 1879
我在风中等你
我在风中等你 2021-02-06 09:01

I am currently automating our iOS testing on jenkins. So far I had no problems with running unit tests, converting OCUnit into JUnit and generating code coverage in Cobertura fo

2条回答
  •  梦如初夏
    2021-02-06 09:13

    Following these steps, I was able to generate the code coverage files from UI Automation and display the information through the cobertura Jenkins plugin.

    First set the “Generate Test Coverage Files” and “Instrument Program Flow” build settings to Yes. This will generate code coverage files every time you run your application in the simulator and exit the application. Add UIApplicationExitsOnSuspend in your Info.plist file and set this option to 'YES'. Run the UI automation test and at the end of it you can exit the app either by manually pressing the HOME button in the simulator or using the UIATarget.localTarget().deactivateAppForDuration() method. Note if your app has any UI Automation tests that rely on the deactivateAppForDuration() method, the tests will terminate upon running the command.

    Once you have the gcda files you can generate the cobertura xml file by downloading gcovr (https://software.sandia.gov/trac/fast/wiki/gcovr) and running the command

    gcovr -r your_root_directory --object-directory path_to_gcda_files --xml > coverage.xml

    With that you can setup the Jenkins cobertura plugin to display the information as needed.

    Source: http://blog.octo.com/en/jenkins-quality-dashboard-ios-development/#step2-2

提交回复
热议问题