Currently, there are few UI-related automated tests for iOS development.
Currently Xcode provides UI Automation,ui testing Bundle, both of which have the advantage of automatically generating test code by recording a real simulator or a real-world operation. And no need for an extra environment, just need xcode. But the flaws are obvious, Is the automatic generation of code enforceability, and maintainability is poor. Minor changes on the page will cause the case to not work properly.
Earygrey is a set of iOS UI testing frameworks provided by Google, based on the unit testing Bundle, which ensures that page elements can be obtained through matcher and Condition,matcher. condition to ensure that case execution succeeds through conditional judgment.
Earygrey integration has two ways, one is through Cocoapods, one is github to download the source code itself to build the framework to add dependencies
Source Address: Https://github.com/google/EarlGrey
Earygrey Integration:
1. Create a new test target in the project where you need to test and select "IOS Unit testing Bundle".
2. Create a new target import earlgrey.framework (this article uses its own compiled framework)
3. New Target,build phases>add new Copy File phases (reference image)
4. New Scheme,product>scheme>new Scheme,target Select New test
5. Edit Scheme,product>scheme>manager schemes, just new Scheme Select shared
6. Edit the original target Scheme
Key: ' dyld_insert_libraries ' Value: ' @executable_path/earlgrey.framework/earlgrey '
7. Test target New TestCase
-(void) testexample {[[Earlgrey Selectelementwithmatcher:grey_keywindow ()] assertwithmatcher: Grey_sufficientlyvisible ()];}
8.command+u performing Tests
How to test automatically?
' Platform=ios simulator,name=iphone 6,os=9.3 ' tail -F Test.log
The Xcodebuild Terminal command executes the unit test. This allows for timed execution and statistical output logs.
Earlgrey is a more complete set of UI automated testing solutions that previously relied too much on labor. This automated test approach will greatly increase efficiency.
Earlgrey iOS Automated UI test (integration)