简体   繁体   English

单元测试未编译 - Swift Xcode 9.2

[英]Unit tests not compiling - Swift Xcode 9.2

I am learning some TDD for Swift and I came across an issue that Xcode wont compile my test code.我正在为 Swift 学习一些 TDD,我遇到了一个问题,即 Xcode 不会编译我的测试代码。 I have no clue what could be wrong with this.我不知道这有什么问题。

Other tests are working fine (also tests for "ListItem" and "Location").其他测试工作正常(还有“ListItem”和“Location”的测试)。 I also closed Xcode many times and cleared Derived Data and even the project itself.我也多次关闭 Xcode 并清除派生数据甚至项目本身。

Below the screenshots of code and compile error.下面是代码和编译错误的截图。 If I change the "ListItem" parameter in the method to "Any" (and change the type of the array also), it is compiling.如果我将方法中的“ListItem”参数更改为“Any”(并同时更改数组的类型),则它正在编译。 But this is not the code I want without the specific type.但这不是我想要的没有特定类型的代码。

Thanks!谢谢!

在此处输入图片说明

在此处输入图片说明

Found the solution here: swift Xcode unit test: Cannot convert value of type "Person" to expected argument type "Person"在这里找到解决方案: swift Xcode 单元测试:无法将“Person”类型的值转换为预期的参数类型“Person”

Seems that the ItemManager .swift file was not added to the test target of the project (derp)..似乎 ItemManager .swift 文件没有添加到项目(derp)的测试目标中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM