Kharon
Kharon (/ˈkɛərɒn, -ən/; Greek Χάρων) is the ferryman of Hades who carries souls of the newly deceased across the rivers Styx and Acheron that divided the world of the living from the world of the dead.
Kharon is a tiny framework that improves the exchange of data between the UI tests and the app processes.
Forget about serializing and decoding data, as Kharon does that for you.
Usage
Kharon is made of two small frameworks, Kharon itself and KharonUITests.
The first should be linked against the app target, and the second one against the UI tests target.
Requirements
As Kharon relies on Swift property wrappers, the minimum required version of the Swift toolchain is: 5.1
.
Xcode >= 11.x
App Target
Add Kharon to your main app target, and decorate the data you wish to receive from UI tests with the UITestFerry
property wrapper.
UITestFerry
requires a value to beOptional
and conforming toCodable
protocol.
import Kharon
import UIKit
final class SomeViewController: UIViewController {
@UITestFerry("someViewController.title")
var uiTestsTitle: String?
}
UI Tests Target
Add KharonUITests to the UI Tests target, and decorate the data you want to send to the app with the AppFerry
property wrapper.
Populate the data, then inject Kharon into your XCApplication
instance, before launching it.
import KharonUITests
import XCTest
final class SomeTestCase: XCTestCase {
@AppFerry("someViewController.title")
var uiTestsTitle: String?
func test_inject_title() throws {
uiTestsTitle = "UI Tests"
try Kharon.inject(into: /* XCUIApplication */)
}
}
AppFerry
requires a value to beOptional
and conforming toCodable
protocol.
Installation
SwiftPM
Add this github repo to Xcode 11.x
File -> Swift Packages -> Add Swift Dependency
and enter:
https://github.com/Zi0P4tch0/Kharon
Link Kharon against your app target, and KharonUITests against the ui tests target.
Carthage
github "Zi0P4tch0/Kharon" "0.1.0"
Link Kharon against your app target, and KharonUITests against the ui tests target.
Cocoapods
target App do
pod "Kharon", "~>0.1.0"
end
target AppUITests do
pod "KharonUITests", "~>0.1.0"
end
Demo
Clone this repo, anche check out DemoApp and DemoAppUITests to see Kharon at work.
License
Copyright (c) 2019 Matteo Pacini
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.