0


Let me explain the problem first before asking for a solution. We have Appium automation tests for our iOS app. We believe that every test should start from a clean slate (i.e. app installation) instead of relying a previous test to bring the app to the screen the current test in question is interested in. I am hoping that this approach is correct. We try to generate .gcda file using the approach mentioned here. But the clean state approach seems to create multiple .gcda file for every test. How to merge it in a simpler way than the approach mentioned here (looks like multiple steps - if there are too many .gcda files, we will need multiple steps). We want this coverage through Appium till we add unit tests for legacy code, so we don't feel it is needed to integrate this complicated approach for code coverage via Appium into CI, so doing manually every time we need the coverage, will mean converting all .gcda to LCOV files, which may be time consuming. Hence this question.

Thanks,

Paddy

Community
  • 1
  • 1
Paddy
  • 3,472
  • 5
  • 29
  • 48

1 Answers1

0

You just need to add capabilities for full reset of the application before the test. It works on real devices just as well as on simulators.

capabilities.setCapability("fullReset", true)
capabilities.setCapability("noReset", false)

If you need to reload application without clearing some cache then I suggest using following capabilities:

capabilities.setCapability("fullReset", false)
capabilities.setCapability("noReset", true)

and for application reload use this function (iOS only!):

static reloadApplication() {           
        mobileDriver.closeApp()
        mobileDriver.launchApp()            
}
  • Hi @Kristaps, just to confirm so that I am not missing anything here, which version of iOS are you using and which version of Appium? My requirement is that it should uninstall the app after every test without clearing the app data (the gcovr files are getting stored as part of app's data). Is that what you say is working for you on real iOS device? – Paddy Nov 11 '16 at 11:41
  • I am not sure about such technical specifics as `.gcovr`, but to reset app so that user is not logged in any more I use these capabilities. Appium v1.5.3. iOS v9.1 and v9.3.5 – Kristaps Mežavilks Nov 11 '16 at 11:55
  • Hi @Krishtaps, that means you are referring a reset and not a re-install or uninstall of the app per se? Is that correct? – Paddy Nov 11 '16 at 11:58
  • I updated my answer. First case is for full reset when application is uninstalled and re-installed again. Second case is when application is closed and re-started without cache clearing. – Kristaps Mežavilks Nov 11 '16 at 12:01
  • Hi @Kristaps, what is the difference between the first two lines where you set fullReset to true and noReset to false? Which one retains App data? Also what if I see the error mentioned by another user here below? – Paddy Nov 13 '16 at 05:56
  • Just to be clear @Kristaps, I meant two similar looking code snippets (both set fullReset to true and noReset to false) above but above one of them, you have mentioned it does not clear cache, hence my confusion. – Paddy Nov 13 '16 at 06:08
  • @Paddy, sorry my mistake. Second case must allow no reset and the process itself saves the data because you are not performing full reset. – Kristaps Mežavilks Nov 14 '16 at 10:00
  • Hi @Kristaps, thank you for your reply. My requirement is that the app must be installed before every test yet I should be able to collect .gcda files. Team mates who tried say that right now we collect these coverage files inside app's data folder that gets wiped with uninstall. In that context,it looks to me that both fullReset=true/noReset=false (uninstalls but wipes data) and fullReset=false/noReset=true (does not erase data but does not uninstall?) won't be applicable? Please correct me if my understanding is wrong. – Paddy Nov 14 '16 at 17:18