-->

在XCTestCase类访问的应用程序的委托对象导致misaligned_stack_error_迅

2019-10-20 16:27发布

我试图在迅速进行单元测试。

我定义我的测试用例类是这样的:

import XCTest
import CoreData
import UIKit

class LazyLoadingCheckTests: XCTestCase {

    var appDelegate : AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate

    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.
        XCTAssert(true, "Pass")
    }
}

每当我试图执行一个测试用例,断点自动停在下面一行:

它显示以下堆栈跟踪:

当我尝试继续它显示了这一点:

任何线索?

文章来源: accessing app delegate object in XCTestCase class causes misaligned_stack_error_ swift