@Code Various answers are legal. Here are two other options, or rather, workarounds :
Property Based Testing
You can use a tool like Fox to do generative testing, where the test structure will generate many input sets for the behavior that you want to test and run for you.
More on this approach:
Common BDD Examples
If you like the BDD style and use a test environment that supports them, you can use common examples .
Using Quick , it will look like this:
class MultiplySharedExamplesConfiguration: QuickConfiguration { override class func configure(configuration: Configuration) { sharedExamples("something edible") { (sharedExampleContext: SharedExampleContext) in it("multiplies two numbers") { let a = sharedExampleContext()["a"] let b = sharedExampleContext()["b"] let expectedResult = sharedExampleContext()["b"] expect(multiply(a, b)) == expectedResult } } } } class MultiplicationSpec: QuickSpec { override func spec() { itBehavesLike("it multiplies two numbers") { ["a": 2, "b": 3, "result": 6] } itBehavesLike("it multiplies two numbers") { ["a": 2, "b": 4, "result": 8] } itBehavesLike("it multiplies two numbers") { ["a": 3, "b": 3, "result": 9] } } }
Honestly, this option: 1) a lot of work, 2) improper use of the general example method, since you do not use them to test the behavior shared by several classes, but rather to parameterize the test. But, as I said at the beginning, this is a more workaround.
source share