TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Feb 2016 |
SPMSupports SPM | ✗ |
Maintained by recruit-mp.
Split Testing for Swift.
ABKit is a library for implementing a simple Split Test that:
let defaultVersion = Version(name: "A") { version in print("Pattern \(version.name)") }
let test = SplitTest(name: "Sample A/B test", defaultVersion: defaultVersion)
let b = Version(name: "B") { version in print("Pattern \(version.name)") }
test.addVersion(b, weight: 0.5)
test.run() // A(Default Version) = 50%, B = 50%
let defaultVersion = Version(name: "A") { version in print("Pattern \(version.name)") }
let test = SplitTest(name: "Sample split test", defaultVersion: defaultVersion)
let b = Version(name: "B") { version in print("Pattern \(version.name)") }
test.addVersion(b, weight: 0.2)
let c = Version(name: "C") { version in print("Pattern \(version.name)") }
test.addVersion(c, weight: 0.3)
test.run() // A(Default Version) = 50%, B = 20%, C = 30%
let defaultVersion = Version(name: "A") { version in print("Pattern \(version.name)") }
let test = ConditionalTest<User>(name: "Sample conditional test", defaultVersion: defaultVersion)
let b = Version(name: "B") { version in print("Pattern \(version.name)" }
test.addVersion(b) { user in user.age < 20 }
let user = User(name: "naoty", age: 28)
test.run(user) // If user.age < 20 is true, B will be run otherwise A will be run.
ABKit
selects one of the versions using a random number, which is saved in RandomNumberRepository
. By default, ABKit
uses NSUserDefault
as RandomNumberRepository
. You can save it in any storage by implementing RandomNumberRepository
protocol.-setRandomNumber(_:)
and reset a random number using -deleteRandomNumber()
for SplitTest
.ABKit is available under the MIT license. See the LICENSE file for more info.