简体   繁体   中英

Xcode lost button test in xctest

I working on Xcode 6. When I coding XCTest, Xcode has been crash. When I reopen my Xcode, and it lost little diamond run button.

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.

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. 3.Select Unit test and all would be good to go.

Prefix func name with test

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.

在此处输入图片说明

  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

  2. Delete this setting

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

This should reenable indexing and should bring back the individual test button (diamond shaped) in the subsequent Xcode launch.

A possible answer for some - I had added a new scheme in my XCode, but the tests were only in the original scheme. 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.

在此处输入图片说明

Solution that is working for me in Xcode 13 , SWIFT 5 :

Open another Xcode file and then open the file wth your function again, the button should appear then.

I just re-started my Xcode and it worked. as everything was set-up the way it should be !!

Prefix func name with test

example test function name:

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

then clean the build file use this shortcut key command + shift + k

Need More description? But Try following troubleshooting... check Target Membership of test file

Go to,

Xcode > Window > Projects

click on the delete button for derived data. Close XCode and open again. You should be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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