Xcode tests stuck in testing state

Issue: When I click run unit tests the tests get 'stuck' and in the top bar is says "Testing..." and never completes - I even left it for an hour.

I have created new projects with no code written and the same thing happens.

I have deleted and re-downloaded code as well.

Current Xcode: 14.3

I don't believe it's a project issue since I have tried multiple but rather something with Xcode.

and my CPU % for Xcode shoots to 365+ when this is happening. I have a M1 Max with 64GB.

Any help would be appreciated.

I had the same issue. Don't know if it had any effect, but I moved Xcode from my Downloads folder to Applications, then tried again. It did get stuck, so I started looking at Console to see if there were any clues. While I was doing this the tests eventually started. Took about 5 minutes?

Also had the same issue, what worked is deactivating the "Execute in parallel" in the Tests options (Edit scheme -> Choose Test -> Select Test Plan and go to Options)

24

The same issue

Same here. In addition, when I opened Console, there were a constant stream of Xcode errors similar to this: "found no value for key DVTShowAllSimulatorRunDestinations in CFPrefsSearchListSource<0x600000679780> (Domain: com.apple.dt.Xcode, Container: (null))" Switching off the "Execute in parallel (if possible)" option helped to run tests, but the errors stream in console didn't stop. Xcode Version 15.0 (15A240d).

I have the same problem Xcode 14.3.1, the workaround (disable running tests in parallel) didn't help.

Maybe you use in your XCTestCase

override func setUp(completion: @escaping ((any Error)?) -> Void) { }

    override func tearDown(completion: @escaping ((any Error)?) -> Void) {} 

and never call the completion(), to let it continue

also you can forget to use

expectation.fulfill()

, that in some chain never called, when you use:

let expectation = self.expectation(description: "testCurrentUser")
waitForExpectations(timeout: 5, handler: nil)
Xcode tests stuck in testing state
 
 
Q