【发布时间】:2014-10-12 11:46:23
【问题描述】:
我正在将 Swift 与 Typhoon 和 Cocoapods 一起使用。在我开始为我的 Typhoon 组件编写集成测试(根据Typhoon-Example-App Test)之前,一切都运行良好。我想在测试setUp() 方法中设置TyphoonFactory,就像我在AppDelegate 中所做的那样。当我执行测试时,我总是得到一个
TyphoonBlockComponentFactory assertIsAssembly:] + 244: 错误:MyApp.MyAssembly 不是 TyphoonAssembly 的子类
Typhoon 引发的错误(它在后台使用 kindOfClass 方法。)相同的代码在 AppDelegate 中完美运行,我不知道出了什么问题。
为了验证这种行为,我在展位类中实现了isKindOfClass check in(参见下面的代码):
- AppDelegate -> 真
- MyComponentTest -> 假
有人可以进一步帮助我吗? 非常感谢!
PodFile
inhibit_all_warnings!
target "MyApp" do
pod 'Typhoon', '2.1.0'
end
target "MyAppTests" do
pod 'Typhoon', '2.1.0'
end
MyAssembly.swift
public class MyAssembly : TyphoonAssembly{
//Some definitions
}
AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
…
var assembly : MyAssembly = MyAssembly()
//Always returns „true“
println("Is type of class: \(assembly.isKindOfClass(TyphoonAssembly))")
…
}
MyComponentTest.swift
import XCTest
import MyApp
class MyComponentTest: XCTestCase {
override func setUp() {
super.setup()
var assembly : MyAssembly = MyAssembly()
//Always returns „false“!
println("Is type of class: \(assembly.isKindOfClass(TyphoonAssembly))")
//Error is thrown „MyApp.MyAssembly is not a sub-class of TyphoonAssembly“
var factory : TyphoonComponentFactory = TyphoonBlockComponentFactory(assembly: assembly) as TyphoonComponentFactory
}
}
【问题讨论】:
-
你的班级是 MyAssembly 还是 ONETyphoonAssembly?你能提出一个 GitHub 问题并提交示例代码吗? . .我们仍在努力支持 Swift。
-
感谢 TyphoonGroup 我通过从 PodFiles“MyAppTests”部分删除 Typhoon 依赖项解决了这个问题。更多详情见Typhoon-Issue
标签: ios swift xctest typhoon xcode6-beta5