Ios XCTest中的Swift TyphonBlockComponentFactory错误

Ios XCTest中的Swift TyphonBlockComponentFactory错误,ios,swift,xctest,typhoon,xcode6-beta5,Ios,Swift,Xctest,Typhoon,Xcode6 Beta5,我用的是斯威夫特和台风以及椰子荚。在我开始为我的Typhone组件编写集成测试(根据)之前,一切都很顺利。我想在Testsetup()方法中设置typhonfactory,方法与在AppDelegate中相同。当我执行测试时,我总是得到一个 TyphonBlockComponentFactory断言汇编:+244:错误:MyApp.MyAssembly不是TyphonAssembly的子类 台风引发的错误(它在引擎盖下使用了类的方法)。相同的代码在AppDelegate中工作得很好,我不知道出了

我用的是斯威夫特和台风以及椰子荚。在我开始为我的Typhone组件编写集成测试(根据)之前,一切都很顺利。我想在Test
setup()
方法中设置
typhonfactory
,方法与在
AppDelegate
中相同。当我执行测试时,我总是得到一个

TyphonBlockComponentFactory断言汇编:+244:错误:MyApp.MyAssembly不是TyphonAssembly的子类

台风引发的错误(它在引擎盖下使用了类的
方法)。相同的代码在
AppDelegate
中工作得很好,我不知道出了什么问题

为了验证这种行为,我实现了
isKindOfClass
check-in-booth类(参见下面的代码):

  • AppDelegate->true
  • 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
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    …
    var assembly : MyAssembly = MyAssembly()
    //Always returns „true“
    println("Is type of class: \(assembly.isKindOfClass(TyphoonAssembly))")
    …
}
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
    }
}
AppDelegate.swift

public class MyAssembly : TyphoonAssembly{
    //Some definitions
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    …
    var assembly : MyAssembly = MyAssembly()
    //Always returns „true“
    println("Is type of class: \(assembly.isKindOfClass(TyphoonAssembly))")
    …
}
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
    }
}
MyComponentTest.swift

public class MyAssembly : TyphoonAssembly{
    //Some definitions
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    …
    var assembly : MyAssembly = MyAssembly()
    //Always returns „true“
    println("Is type of class: \(assembly.isKindOfClass(TyphoonAssembly))")
    …
}
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
    }
}

为了其他用户的利益:

如上所述,当台风椰子荚包含在应用程序目标和测试目标中时,会发生此错误

由于应用程序样式测试(设置了TEST_HOST标志)现在几乎在任何地方都是默认的,因此测试目标会自动从主应用程序目标继承依赖项。在Swift的情况下,如果在测试目标中重复,则使用名称间隔,可能会出现问题

因此,解决方案是从测试目标中删除Typhone和任何其他应用程序的依赖项,因为这些依赖项是继承的。您仍然可以包括测试特定的依赖项,如下所示:

target :tests, :exclusive => true do
   pod 'OCMockito'
   pod 'AnotherTestLibrary' #etc . . 
end

您的类是MyAssembly还是ONETyphoonAssembly?您能否提出GitHub问题并提交示例代码。我们仍在进行Swift支持。完成:Thx to TyphongGroup我通过从PodFiles“MyAppTests”部分删除Typhone依赖项解决了问题。有关更多详细信息,请参阅OCMock的相同解决方案。再一次Jasper you rock!这是正确的答案,并立即解决了我的问题:)