This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func setUpWithError() throws { | |
continueAfterFailure = false | |
if TestObserver.shared.shouldSkipAllTests { | |
throw XCTSkip("Too many tests have failed, skipping remainder") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
/// Observes test failures and suggests skipping remaining tests when too many have failed | |
class TestObserver: NSObject { | |
static let shared = TestObserver() | |
/// The number of failed tests before the observer will report that remaining tests should be skipped. | |
/// This allows test runs to be cut short if numerous tests are failing, indicating an environment issue that's pointless to battle on against. | |
private let failureTolerance: UInt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verify(StorageThing) | |
.hasNoEntry("something") | |
sut = UnitBeingTested() | |
verify(StorageThing) | |
.hasEntry("something") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sut = UnitBeingTested() | |
verify(StorageThing) | |
.hasEntry("something") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mockedDependency = mock(DependencyOfUnitBeingTested) | |
sut = UnitBeingTested("a value", mockedDependency) | |
verify(sut.value) | |
.is("a value") | |
verify(mockedDependency) | |
.callMadeTo(functionCalledByUnitBeingTested) | |
.withParameter("a value") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sut = UnitBeingTested("a value") | |
verify(sut.value) | |
.is("a value") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delegate = ADelegate() | |
sut = UnitBeingTested(delegate) | |
sut.aFunctionCall() | |
verify(delegate) | |
.callMadeTo(onSuccess) | |
verify(delegate) | |
.callNOTMadeTo(onError) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delegate = ADelegate() | |
sut = UnitBeingTested(delegate) | |
sut.aFunctionCall() | |
verify(delegate) | |
.callMadeTo(onSuccess) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delegate = ADelegate() | |
sut = UnitBeingTested(delegate) | |
sut.aFunctionCall() | |
verify(delegate) | |
.callMadeTo(functionOnDelegate) | |
.withParameter("1234") |
NewerOlder