Ninh
Ninh

Reputation: 149

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:

https://i.sstatic.net/6OGSn.png

But it got:

https://i.sstatic.net/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.

Upvotes: 9

Views: 6895

Answers (12)

Gopala Krishnan S
Gopala Krishnan S

Reputation: 241

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

Upvotes: 0

Ali
Ali

Reputation: 2487

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

Upvotes: 1

Zaim Ramlan
Zaim Ramlan

Reputation: 591

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.

Upvotes: 3

stackich
stackich

Reputation: 5297

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.

Upvotes: -1

golldy
golldy

Reputation: 1299

Go to,

Xcode > Window > Projects

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

Upvotes: -1

johnnyb
johnnyb

Reputation: 712

A possible answer for some - I had added a new scheme in Xcode, but the tests were only in the original scheme. Switching back to the original scheme re-instated my tests.

Upvotes: 1

Omer Malik
Omer Malik

Reputation: 409

  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 the Unit Test target and all would be good to go.

Upvotes: 5

Marcos Reboucas
Marcos Reboucas

Reputation: 3489

In Xcode 12.4 just Command+U or menu Product > Test and all buttons in your XCTestCase will appear again.

enter image description here

Upvotes: 1

Manikandan Selvanathan
Manikandan Selvanathan

Reputation: 915

My issue was file was not included in the workspace. If not included, go to finder and drag and drop to that folder.

Upvotes: 1

ChanOnly123
ChanOnly123

Reputation: 1034

Prefix func name with test

Also try changing the targets

enter image description here

Upvotes: 11

Firda Sahidi
Firda Sahidi

Reputation: 1281

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.

enter image description here

  1. Click on your test class, then click right panel. In target membership, checklist the tests target.

enter image description here

Upvotes: 3

bhavesh
bhavesh

Reputation: 109

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

Upvotes: -1

Related Questions