AB testing framework for iOS

Related tags

Testing ABKit
Overview

ABKit

Build Status

Split Testing for Swift.

ABKit is a library for implementing a simple Split Test that:

  • Doesn't require an HTTP client
  • written in Pure Swift

Installation

CocoaPods

To integrate ABKit into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'ABKit'

Then, run the following command:

$ pod install

Usage

A/B Test

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%

Split Test with Weighted Probabilities

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%

Conditional Test

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.

Pro Tips

  • 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.
  • You can specify an arbitrary number as the random number using -setRandomNumber(_:) and reset a random number using -deleteRandomNumber() for SplitTest.

License

ABKit is available under the MIT license. See the LICENSE file for more info.

You might also like...
Multivariate & A/B Testing for iOS and Mac

This library is no longer being maintained. You can continue to use SkyLab in your projects, but we recommend switching another solution whenever you

An understated approach to iOS integration testing.
An understated approach to iOS integration testing.

Subliminal is a framework for writing iOS integration tests. Subliminal provides a familiar OCUnit/XCTest-like interface to Apple's UIAutomation frame

Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine
Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine

Bluepill is a tool to run iOS tests in parallel using multiple simulators. Motivation LinkedIn created Bluepill to run its large iOS test suite in a r

iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase.
iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase.

SnappyTestCase iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase. Why? Snapshot testing helps to deliver views that

Sample project for testing out focus in SwiftUI and iOS 15

This project was to test out different ways of enabling focus in a SwiftUI app.

A flexible mock server for automated and regression testing of iOS, Android and other apps.
A flexible mock server for automated and regression testing of iOS, Android and other apps.

Note: This document is intended as a quick introduction to Voodoo. As Voodoo has a large number of features, please refer to Voodoo's Github Wiki for

Network testing for Swift

DVR DVR is a simple Swift framework for making fake NSURLSession requests for iOS, watchOS, and OS X based on VCR. Easy dependency injection is the ma

UI Testing Cheat Sheet and Examples.

UI Testing Cheat Sheet This repository is complementary code for my post, UI Testing Cheat Sheet and Examples. The post goes into more detail with exa

Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS
Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS

Mockingbird Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS, allowing a team to test and develop

Comments
  • if random number is initialized to 0, it will be reset on next run()

    if random number is initialized to 0, it will be reset on next run()

    generateRandomNumber() return a number in [0,99] stored integer is tested against 0 so there is 1 chance out of 100 that number will change:

        public func ab_getRandomNumberWithKey(key: String) -> Int {
            var randomNumber = integerForKey(key)
            if randomNumber == 0 {
                randomNumber = generateRandomNumber()
                setInteger(randomNumber, forKey: key)
            }
            return randomNumber
        }
    
    opened by jauboux 0
Owner
Recruit Marketing Partners Co.,Ltd
Recruit Marketing Partners Co.,Ltd
Testing the UI without UI Testing, a Swift experiment.

UI tests without UI Testing experiment This repo is a small experiment to see if there's an "in-between" for testing iOS applications. More feature-le

Joe Masilotti 20 Sep 26, 2022
Remote configuration and A/B Testing framework for iOS

MSActiveConfig v1.0.1 Remote configuration and A/B Testing framework for iOS. Documentation available online. MSActiveConfig at a glance One of the bi

Elevate 78 Jan 13, 2021
AB testing framework for iOS

ABKit Split Testing for Swift. ABKit is a library for implementing a simple Split Test that: Doesn't require an HTTP client written in Pure Swift Inst

Recruit Marketing Partners Co.,Ltd 113 Nov 11, 2022
Keep It Functional - An iOS Functional Testing Framework

IMPORTANT! Even though KIF is used to test your UI, you need to add it to your Unit Test target, not your UI Test target. The magic of KIF is that it

KIF Framework 6.2k Dec 29, 2022
The Swift (and Objective-C) testing framework.

Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. // Swift import Quick import Nimbl

Quick 9.6k Dec 31, 2022
Genything is a framework for random testing of a program properties.

Genything is a framework for random testing of a program properties. It provides way to random data based on simple and complex types.

Just Eat Takeaway.com 25 Jun 13, 2022
T - A simple testing framework using closures and errors

t Quickly test expectations What is t? t is a simple testing framework using clo

OpenBytes 6 Nov 7, 2022
Snapshot testing tool for iOS and tvOS

SnapshotTest is a simple view testing tool written completely in Swift to aid with development for Apple platforms. It's like unit testing for views.

Pär Strindevall 44 Sep 29, 2022
Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5 and iOS 15.

StoreHelper Demo Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5, iOS 15. See also In-App Purchases with Xcode 12 and

Russell Archer 192 Dec 17, 2022
A Mac and iOS Playgrounds Unit Testing library based on Nimble.

Spry Spry is a Swift Playgrounds Unit Testing library based on Nimble. The best thing about Spry is that the API matches Nimble perfectly. Which means

Quick 327 Jul 24, 2022