Combinations

Twitter: @amaimescu License

Combinations is an iOS testing utility framework suited for fast boundary testing.

Boundary testing or boundary value analysis, is where test cases are generated using the extremes of the input domain, e.g. maximum, minimum, just inside/outside boundaries, typical values, and error values. It is similar to Equivalence Partitioning but focuses on corner cases.

The framework does just two simple things:

  1. Generate a set of combinations from test data input set;
  2. Generate a run-time unit or UI test for each of the combinations;

Check out the API reference for more information.

Simple example:

We have an input form with four fields: First Name, Email, Password and Gender.

We also have our testing boundary values defined for each field:

  • First Name: John Smith, empty string
  • Email: john.smith@example.com, john.smith@, empty string
  • Password: 12345, ~@#123ABC, empty string
  • Gender: Male, Female

Combinations gets a set of input test data values and transforms it in run-time tests for each generated combination of values.

So for our example the combinations will be:

  • [John Smith, john.smith@example.com, 12345, Male]
  • [John Smith, john.smith@example.com, 12345, Female]
  • [John Smith, john.smith@example.com, ~@#123ABC, Male]
  • [John Smith, john.smith@example.com, ~@#123ABC, Female]
  • etc.

For each of this combinations will be generated a test (XCTestCase)

A running example of the UI Tests generated by Combinations:

Combinations

Installation

Carthage

If you are using Carthage, you can always use it to build the library within your workspace by adding the line below to your Cartfile.

github "alexmx/Combinations"

CocoaPods

If you are using CocoaPods, you can as well use it to integrate the library by adding the following lines to your Podfile.

platform :ios, '8.0'
use_frameworks!

target 'YourAppTarget' do
    pod "Combinations"
end

Manual installation

In order to include the Combinations library into your project, you need to build a dynamic framework from provided source code and include it into your project, or inlcude the entire Combinations library as sub-project by copying it to your project directory or include as Git submodule.

Usage

The library requires just two methods to be overriden: valuesForCombinations and assertCombination:

import XCTest
import Combinations

class MyTests: CombinationsSpec {

    override func setUp() {
        super.setUp()
    }

    // Provide input values for Combinations
    override class func valuesForCombinations() -> [[Any]]? {
        return [
            [1, 2, 3, 4],
            ["John Smith", "John", ""]
        ]
    }

    // This method will be called for each generated combination:
    // [1, "John Smith"], [1, "John"], [1, ""], [2, "John Smith"], etc.
    override func assertCombination(_ combination: [Any]) {

        // Perform required asserts on combination
    }
}

License

This project is licensed under the terms of the MIT license. See the LICENSE file.