swift Xcode unit test: Cannot convert value of type “Person” to expected argument type “Person”

匿名 (未验证) 提交于 2019-12-03 02:31:01

问题:

I am trying to write a unit test class to test my custom classes. When I am trying to call a method in the custom class with a custom object as the input variable, I got: 'Cannot convert value of type "Person" to expected argument type "Person". "Person" is the class, inherited from NSManagedObject, where the input object was created from. I have no problem with other methods taking other value type. The method works fine. The test class is the only one complains this. Is it a bug or limitation? Any suggestion I can dig deeper on this issue?

回答1:

I was running into this issue earlier. It turns out that the system under test (in my case it was a service calling the object; a PersonService for your example, perhaps) did not have Target membership to the test project. I just clicked the .swift file, and made sure both the main project and test project were checked.

Hope this helps!



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!