iOS单元测试:Class都在两者中实现 [英] iOS Unit Testing: Class is implemented in both

查看:123
本文介绍了iOS单元测试:Class都在两者中实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swift 2和XCode7构建iOS 9应用程序。

I'm building an iOS 9 App with Swift 2 and XCode7.

我的应用程序在部署到我的手机时运行正常。
但是当我运行任何单元测试时,我收到许多类的以下错误消息:

My app runs fine when deploying it to my phone. But when I run any unit test, I get the following error message for a lot of classes:

Class _TtC5 AppName 19 ClassName 在/ Users / 用户名 / Library / Developer / CoreSimulator / Devices / UUID / data / Containers / Bundle / Application / <中实现strong> UUID / AppName .app / AppName 和/ Users / 用户名 / 路径/到/工作区 / DerivedData /的 AppName的 /生成/产品/调试-iphonesimulator /的 AppName的 .xctest /的 AppName的即可。将使用两者之一。哪一个未定义。

Class _TtC5AppName19ClassName is implemented in both /Users/Username/Library/Developer/CoreSimulator/Devices/UUID/data/Containers/Bundle/Application/UUID/AppName.app/AppName and /Users/Username/Path/To/Workspace/DerivedData/AppName/Build/Products/Debug-iphonesimulator/AppName.xctest/AppName. One of the two will be used. Which one is undefined.

任何想法?

推荐答案

仅添加测试类到测试目标,没有iPhone应用程序类。然后只需将您的应用程序名称作为模块导入到测试类之上,即可访问所有应用程序类。

Only add the test class to your test target and none of the iPhone app classes. Then simply import your app name as a module on top of your test class to get access to all app classes.

import MyAppName

这篇关于iOS单元测试:Class都在两者中实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆