I understand that a class is a blueprint of a future object and I'm attempting to get a better grasp of OOP architecture using Swift. So the question I have is, what is the process that happens when you run your tests from a class and instances perspective. I don't think I've actually created an instance of my XCTestCase subclass necessarily but Xcode seems to do this automatically. As I'm building more passion project apps, I usually have to create an instance in order to use it but in testing I don't get that feeling and it just works by hitting (Command + U). I'd like to understand if an instance is even create at all and if so how?
Here's some sample code of a blueprint XCTestCase subclass but I never have to actually instantiate this class:
import XCTest
@testable import FirstDemo
class FirstDemoTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}