简体   繁体   English

Xcode 在 xctest 中丢失按钮测试

[英]Xcode lost button test in xctest

I working on Xcode 6. When I coding XCTest, Xcode has been crash. I working on Xcode 6. 当我编码XCTest时,Xcode已经死机了。 When I reopen my Xcode, and it lost little diamond run button.当我重新打开我的 Xcode 时,它丢失了小菱形运行按钮。

It should be:它应该是:

http://i.stack.imgur.com/6OGSn.png

But it got:但它得到了:

http://i.stack.imgur.com/gpuD5.png

I open other project and it don't have this error.我打开其他项目,它没有这个错误。 But when I create new target, it get same error (in other project).但是当我创建新目标时,它会出现同样的错误(在其他项目中)。

I checked Target Membership, but it checked in target name.我检查了目标成员资格,但它检查了目标名称。 When I choose Test in Product>Test it run but the button not show.当我在 Product > Test 中选择 Test 时,它运行但按钮不显示。

Thank a lot, sorry for my bad english.非常感谢,抱歉我的英语不好。

1.Click on the test file(unit test or UI test file) 2.Go to right panel and You'll see target membership. 1.单击测试文件(单元测​​试或 UI 测试文件) 2.转到右侧面板,您将看到目标成员资格。 3.Select Unit test and all would be good to go. 3.选择单元测试,一切都会好起来的。

Prefix func name with testtest前缀 func 名称

Also try changing the targets也尝试改变目标

在此处输入图片说明

There is two way to check it.有两种方法可以检查它。

  1. If you have multiple scheme, In top of Xcode, make sure you choose Test to run the test.如果你有多个方案,在 Xcode 的顶部,确保你选择了 Test 来运行测试。

在此处输入图片说明

  1. Click on your test class, then click right panel.单击您的测试类,然后单击右侧面板。 In target membership, checklist the tests target.在目标成员中,检查测试目标。

在此处输入图片说明

In case you disabled indexing earlier,如果您之前禁用了索引,

  1. Close all Xcode and Simulator instances关闭所有 Xcode 和 Simulator 实例

  2. Delete this setting删除此设置

    defaults delete com.apple.dt.Xcode IDEIndexDisable
  3. Restart Xcode重启Xcode

This should reenable indexing and should bring back the individual test button (diamond shaped) in the subsequent Xcode launch.这应该会重新启用索引,并且应该在随后的 Xcode 启动中恢复单个测试按钮(菱形)。

A possible answer for some - I had added a new scheme in my XCode, but the tests were only in the original scheme.对某些人来说可能的答案 - 我在我的 XCode 中添加了一个新方案,但测试仅在原始方案中。 Switching back to the original scheme re-instated my tests.切换回原始方案重新设置了我的测试。

My issue was file was not included in the workspace.我的问题是文件未包含在工作区中。 If not included, go to finder and drag and drop to that folder.如果未包含,请转到查找器并将其拖放到该文件夹​​中。

In Xcode 12.4 just Command+U or menu Product > Test and all buttons in your XCTestCase will appear again.在 Xcode 12.4 中,只需Command+U或菜单Product > TestXCTestCase所有按钮都会再次出现。

在此处输入图片说明

Solution that is working for me in Xcode 13 , SWIFT 5 :Xcode 13SWIFT 5 中对我有用的解决方案:

Open another Xcode file and then open the file wth your function again, the button should appear then.打开另一个 Xcode 文件,然后再次使用您的函数打开该文件,按钮应该会出现。

I just re-started my Xcode and it worked.我刚刚重新启动了我的 Xcode 并且它起作用了。 as everything was set-up the way it should be !!因为一切都按照应有的方式设置!

Prefix func name with test测试作为前缀函数名称

example test function name:示例测试 function 名称:

 secondExample() must be **testSecondExample()**

then clean the build file use this shortcut key command + shift + k然后清理构建文件使用这个快捷键command + shift + k

Need More description?需要更多描述? But Try following troubleshooting... check Target Membership of test file但是请尝试以下故障排除...检查测试文件的目标成员资格

Go to,去,

Xcode > Window > Projects Xcode > 窗口 > 项目

click on the delete button for derived data.单击派生数据的删除按钮。 Close XCode and open again.关闭 XCode 并再次打开。 You should be good to go.你应该很高兴去。

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

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