UI Testing with KIF
With KIF, you can easily perform UI tests.
platform "SomeProjTests", :exclusive => true do pod "KIF" end
#import <KIF.h> [tester longPressViewWithAccessibilityLabel:@"Label" value:nil duration:0.5f]; [tester tapViewWithAccessibilityLabel:@"Edit"]; // `UIMenu` Edit [tester enterTextIntoCurrentFirstResponder:@"Hi! Test!"]; [tester tapViewWithAccessibilityLabel:@"return"]; // Keyboard return
Note that Accessibility Label is a text you can see (literally) in every UI elements. (e.g. For label which have text “Label”, its accessibility label is “Label”. For button “Edit”, its accessibility label is “Edit”.)
Using accessibility labels, you can perform UI tests as above.
You can see the result in following Vine.
Is it difficult?
Definitely No. You just need to write one
Podfile while appium requires some setups. There are no prerequisites.
You can tap a view in one-line.
If the view does not exist, simply the test fails. Really simple.
Is the development active?
Yes. The last commit is 4 days ago. (2014/09/13)
The project have started since 2011. You can find the code frequency here.
It seems to be hard to maintain UI tests in a real project?
It’s true. User interfaces are often changed. And so test cases should be changed then.
It is hard to maintain perfect UI tests for real projects.
However, there are some cases which can leverage UI tests 100%.
I recommend using UI tests in following cases.
UI Component Project (UI Library)
Just put some views in a main ViewController for test cases. It is like fixture. So the test won’t be broken.
When you put tons of gesture recognizers, you must be encouraged to write tests for them.
Handling variety of gesture recognizers used to be difficult. You can easily create conflict of gesture.
It should be proven that you do not break the recognizers in automated tests. Otherwise you will get fear of making some change about gestures.
- KIF - https://github.com/kif-framework/KIF
- Google Group Forum (KIF iOS Automated Testing Framework) - https://groups.google.com/forum/#!forum/kif-framework