Powerful E2E UI testing framework for iOS.
Currently it is used in Avito, where we have 700+ E2E UI tests, about 90% of them are green and they helped us to reduce manual testing for already 2 years. We run about 25% on PR and we are working towards executing 100% of tests on pull request, partially by switching from Black Box E2E to Gray Box testing. We are running those tests on 3 platforms and it takes ~40 minutes (total duration of tests is 30+ hours), because we are using Emcee, a test runner that runs tests on multiple machines (note that Mixbox doesn't require Emcee). We're writing Gray Box tests too (where we mock classes, network and everything), but we just started.
If you are enthusiastic about using it in your company, file us an issue. We are making it to be usable by community, however, it is not our main goal.
Actions and checks (obviously)
Per-pixel visibility check
Everything has polling
Fully automatic scrolling
Black box AND gray box testing!
Most of the code is shared between gray box and black box tests, as the most of the features. Both options have their own benefits. Use both approaches to have a good test pyramid.
Page Objects
SwipeAction
, all builtin actions are really extensions).Every cell inside UICollectionView is visible in tests (including offscreen cells)
Customizable inter-process communication between app and tests
Custom values for views that are visible in tests
Network mocking (via NSURLSessionProtocol)
Setting permissions (camera/geolocation/notifications/etc)
Simulation of push-notifications (limitations: only inside active app!)
Opening url from tests
Geolocation simulation
Hardware keyboard (very few key codes are defined, however it can be easily implemented)
Customizable without forking repository
Swift & Objective-C
Tested
Configurable reports (e.g.: Tests
project has integration with Allure, an open sourced reporting system with web UI,
and in Avito we use in-house solution for reports; you can write your own implementation)
In development / not open sourced yet:
There are two ways to use Mixbox.
First is described in Demo, it is oversimplified, basically you just use pod SomePod
.
The second we use in Avito and it looks like this: Tests (see Podfile there).
There are not enough docs yet, so you can try simple approach of linking Mixbox (Demo), but use code examples from Tests.
Xcode 9/10 and older versions are not supported anymore. If you are planning to use the project on different environment and have problems, let us know.
For real examples, see Tests
project. It is most up-to-date open sourced examples of how to use it, but it lacks realism (doesn't show it how to tests are written for a real app).
Example of test that show basic features:
func test() {
// Setting permissions
permissions.camera.set(.allowed)
permissions.photos.set(.notDetermined)
// Functions are useful in page objects and allows
// reusing code, for example, for transitions between states of the app
pageObjects.initial
.authorize(user: testUser)
.goToCvScreen()
// Aliases for simple assertions (you can add your own):
pageObjects.simpleCv.view.assertIsDisplayed()
pageObjects.simpleCv.title.assertHasText("My CV")
// Fully customizable assertions
pageObjects.simpleCv.addressField.assertMatches { element in
element.text != addressFieldInitialText && element.text.isNotEmpty
}
// Network stubbing.
networking.stubbing
.stub(urlPattern: ".*?example.com/api/cv")
.thenReturn(file: "cv.json")
// There is also a monitoring feature, including recording+replaying feature that
// allows to record all network and replay in later, so your tests will not require internet.
// Actions
pageObjects.simpleCV.occupationField.setText("iOS developer")
pageObjects.simpleCV.createCVButton.tap()
}
Declaring page objects:
public final class MapScreen:
BasePageObjectWithDefaultInitializer,
ScreenWithNavigationBar // protocol extensions are very useful for sharing code
{
// Basic locator
public var mapView: ViewElement {
return element("Map view") { element in
element.id == "GoogleMapView"
}
}
// You can use complex checks
// Note that you can create your own matchers like `element.isFooBar()`
public func pin(coordinates: Coordinates, deltaInMeters: Double = 10) -> ViewElement {
return element("Pin with coordinates \(coordinates)") { element in
element.id == "pin" && element
.customValues["coordinates", Coordinates.self]
.isClose(to: coordinates, deltaInMeters: deltaInMeters)
}
}
}
Declaring custom page object elements:
public final class RatingStarsElement:
BaseElementWithDefaultInitializer,
ElementWithUi
{
public func assertRatingEqualsTo(
_ number: Int,
file: StaticString = #file,
line: UInt = #line)
{
assertMatches(file: file, line: line) { element in
element.customValues["rating"] == number
}
}
}
This library includes some code copypasted from other libraries. Sometimes it is a single file, some times it is because we need conditional compilation built in in sources to prevent linking the code in release builds.
EarlGrey
contains EarlGrey
substring somewhere). License is here (Apache). It is visibility checker, setting up accessibility, etc. Original repo: https://github.com/google/EarlGrey#if
clauses were added. Original repo: https://github.com/Flight-School/AnyCodableUsed in tests:
link |
Stars: 134 |
Last commit: 40 minutes ago |
This releases fixes compatibility with Xcode 10.2.1
Basically this release should fix this issue: https://github.com/avito-tech/Mixbox/issues/12
It also contains tons of other changes, refactorings, fixes. It is still not production ready for external developers, so I will not describe changes.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics