简体   繁体   English

如何在Xcode中配置和运行目标C测试用例--XCTest

[英]how to config and run objective C test cases in Xcode--XCTest

I was reading the document of XCTest(and personally i think the documentation for this part is not that enough) and I thought I should give it a try for a new project(a MAC command-line project, not and iOS project). 我正在阅读XCTest的文档(我个人认为这部分文档还不够),我想我应该尝试一个新项目(一个MAC命令行项目,而不是iOS项目)。 and then I faced complaints about linking issues--the test case building failed because the conresponsding class .o(if I am not wrong) files are not found. 然后我面对有关链接问题的投诉-测试用例的构建失败,因为未找到相应的类.o(如果我没记错的话)文件。 (the error mes here was not recorded by me, sorry) (抱歉,我没有记录此错误消息,抱歉)

Then I wanted to delete the test project and in the end I did not even manage to remove the test project. 然后,我想删除测试项目,最后我什至没有设法删除测试项目。 So seriously, how to remove an exsiting project from the solution if the notion in VS applies here? 如此严重,如果VS中的概念在这里适用,如何从解决方案中删除现有项目?

After failing at that, I removed the auto-generated test file and created my own test case file and strangely, although Xcode detects the existence of the new test case and test method, the build failed and it failed with no issues--no linking issue, no syntax or whatever issue but it just failed. 失败之后,我删除了自动生成的测试文件并创建了自己的测试用例文件,尽管Xcode检测到新测试用例和测试方法的存在,但是奇怪的是,构建失败了,并且没有任何问题-没有链接问题,没有语法或其他问题,但是它只是失败了。 Now I do not know how to move on now as I do not even get a complaint or an error. 现在我不知道如何继续前进,因为我什至没有收到投诉或错误。

I don't know enough about the state of your project to be certain what the problem is, but here is something to consider: If Xcode added a new build target for your tests, be sure that the .m files that contain the classes you are testing are included in the new build target. 我对您的项目状态了解不多,无法确定问题所在,但是需要考虑以下几点:如果Xcode为测试添加了新的构建目标,请确保.m文件包含您所使用的类测试包含在新的构建目标中。 You can do this by clicking on the relevant .m file in the Project Navigator and looking at the "Target Membership" in the File Inspector pane. 您可以通过在项目导航器中单击相关的.m文件,然后在“文件检查器”窗格中查看“目标成员身份”来执行此操作。 Make sure the box is checked next to the test target. 确保已选中测试目标旁边的框。

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

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