Created
November 25, 2022 10:06
-
-
Save vuklip/f7673f4aa423738afdb8c920c92f0c6c to your computer and use it in GitHub Desktop.
setUp and tearDown for each test and all tests in suite
This file contains 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
Test Suite 'TestSetUp' started at 2022-11-25 12:45:26.009 | |
t = nans Suite Set Up | |
class func setUp() | |
Test Case '-[UITests.TestSetUp testExampleOne]' started. | |
t = 0.00s Start Test at 2022-11-25 12:45:26.023 | |
t = 0.09s Set Up | |
setUpWithError | |
testExampleOne | |
t = 0.10s Tear Down | |
tearDownWithError | |
Test Case '-[UITests.TestSetUp testExampleOne]' passed (0.107 seconds). | |
Test Case '-[UITests.TestSetUp testExampleTwo]' started. | |
t = 0.00s Start Test at 2022-11-25 12:45:26.130 | |
t = 0.06s Set Up | |
setUpWithError | |
testExampleTwo | |
t = 0.07s Tear Down | |
tearDownWithError | |
Test Case '-[UITests.TestSetUp testExampleTwo]' passed (0.072 seconds). | |
t = nans Suite Tear Down | |
class func tearDown() | |
Test Suite 'TestSetUp' passed at 2022-11-25 12:45:26.207. | |
Executed 2 tests, with 0 failures (0 unexpected) in 0.179 (0.198) seconds |
This file contains 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
// Based on https://stackoverflow.com/a/29822900/5116532 | |
import XCTest | |
class TestSetUp: XCTestCase { | |
// Called once before all tests are run | |
override class func setUp() { | |
super.setUp() | |
print("class func setUp()") | |
} | |
// Called once after all tests are run | |
override class func tearDown() { | |
super.tearDown() | |
print("class func tearDown()") | |
} | |
// Called once before each test is run | |
override func setUpWithError() throws { | |
try super.setUpWithError() | |
print("setUpWithError") | |
} | |
// Called once after each test is run | |
override func tearDownWithError() throws { | |
try super.tearDownWithError() | |
print("tearDownWithError") | |
} | |
func testExampleOne() throws { | |
print("testExampleOne") | |
} | |
func testExampleTwo() throws { | |
print("testExampleTwo") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment