클래스가 미래 객체의 청사진임을 이해하고 Swift를 사용하여 OOP 아키텍처를 더 잘 이해하려고 시도하고 있습니다. 그래서 제가 가진 질문은 클래스와 인스턴스 관점에서 테스트를 실행할 때 일어나는 프로세스는 무엇입니까? 필자는 실제로 내 XCTestCase 서브 클래스의 인스턴스를 생성했다고 생각하지 않지만 Xcode는이 작업을 자동으로 수행하는 것으로 보입니다. 더 많은 열정 프로젝트 앱을 제작할 때마다 그것을 사용하기 위해 인스턴스를 만들어야하지만 테스팅에서는 그 느낌을 얻지 못하고 그냥 Command + U를 눌러서 작동합니다. 나는 인스턴스가 심지어 전혀 생성되는지 이해하고 싶습니다. 그렇다면 어떻게해야할까요?XCTestCase 하위 클래스가 인스턴스화되는 프로세스는 무엇입니까?
여기 청사진 XCTestCase 서브 클래스의 몇 가지 예제 코드입니다하지만 실제로이 클래스의 인스턴스를 필요가 없습니다 :
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.
}
}
}