Skip to content

Instantly share code, notes, and snippets.

@novinfard
Last active July 8, 2021 12:27
Show Gist options
  • Save novinfard/832b0a4305b5ed077a528839b7b80d84 to your computer and use it in GitHub Desktop.
Save novinfard/832b0a4305b5ed077a528839b7b80d84 to your computer and use it in GitHub Desktop.
[Different setup and tear down initialisers] #unitTest
class MyTestClass: XCTestCase {
// get called before first test begins
override class func setUp() {
super.setup()
// do something
}
// get called before running each of the test cases in the class
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func test_sampleTest {
// do something
addTeardownBlock {
// get called ater this specific test case completes
}
}
// get called after running each of the test cases in the class
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
// get called after all tests complete
override class func tearDown() {
// do something
super.tearDown()
}
}
// A convention to naming tests
// func test<System Under Test>_<Condition or State Change>_<Expected Result>() {
//
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment