Ui testing framework


My notes on setting up a UI-testing-framework

100% Carthage .framework support

  • Add the UITestSugar.framework to the Test-project folder ๐Ÿ‘‰ drag it to the frameworks folder. ๐Ÿ‘‰ select the UITestTarget
  • In The UITestTarget ๐Ÿ‘‰ build-phases ๐Ÿ‘‰ click plus-button ๐Ÿ‘‰ Copy files ๐Ÿ‘‰ drag the .framework file into that panel ๐Ÿ‘‰ make sure destination is set to framework.
  • In the UITestSugar project: Add $(PLATFORM_DIR)/Developer/Library/Frameworks to the in โ€œBuild settingsโ€ ๐Ÿ‘‰ โ€œframework search pathsโ€
  • Then add the magic build settings setting that I have not been able to identify. What I do is i clone this project: https://github.com/shindyu/XCTestExtensions And then clean it up and use it as a base. You can also rename the project etc. To find the magic setting, we can diff the .proj file. But I was not able to find the missing piece as of now.
  • โš ๏ธ๏ธ (Optional-step) โš ๏ธ๏ธ Use Cartfile.private file instead of Cartfile because these dependencies will only be needed in this local project. And does not need to be visible for other dependencies higher up the hierarchy

Add UITestSugar / TestRunner to projects:

  • Add github "eonist/TestRunner" "master" and github "eonist/UITestSugar" "master" to Cartfile
  • Terminal: carthage update --platform ios
  • In The UITestTarget ๐Ÿ‘‰ build-phases ๐Ÿ‘‰ click plus-button ๐Ÿ‘‰ Copy files ๐Ÿ‘‰ drag the .framework file into that panel ๐Ÿ‘‰ make sure destination is set to framework.
  • Add import UITestSugar and import TestRunner to the top of your .swift files and hit cmd + U to run the UITest

Nesting UI-Testing frameworks

  • Use the same methodology as Non-nested UI-testing frameworks.

Partial carthage solution: (for the sake of reference, dont use this)

  • Add XCTest.framework in the linked framework and libraries list in General.
  • You have to add Framework search-path: $(PLATFORM_DIR)/Developer/Library/Frameworks in Build settings
  • import MyTestFramework
  • Limitations: โš ๏ธ๏ธ I have not been able to load this kind of framework as a pure .framework through carthage, seems the .framework cant find the correct paths somehow. But you can load the src code from carthage and then build the .framework from that src code. Its a bit more hassle to manage src files, but with some more digging I think its possible to figure out the path issue

Resources:

Gotchas: