Tests seem to not be completing

FYI: I'm running Xcode 14.0.1 and the protocol-beta branch.

I initially had this error... New warning in TCA Example tests using Xcode 14 - #3 by mbrandonw

Which I have silenced using the _ = fix for now.

But now, in my test it seems that it isn't actually completing and I'm not sure why.

I've got this test...

func testDeviceUserError() async throws {
	let store = TestStore(
		initialState: AppFeature.State(),
		reducer: AppFeature()
	)

	_ = await store.send(.verifying(.deviceUserError(""))) {
		$0 = .login(.init())
	}
}

And in the logs it says...

Test Suite 'All tests' started at 2022-09-26 09:19:00.789
Test Suite 'AppFeatureTests.xctest' started at 2022-09-26 09:19:00.790
Test Suite 'AppCoreTests' started at 2022-09-26 09:19:00.790
Test Case '-[AppFeatureTests.AppCoreTests testAnalytics]' started.
Test Case '-[AppFeatureTests.AppCoreTests testAnalytics]' passed (0.009 seconds).
Test Case '-[AppFeatureTests.AppCoreTests testDeviceUserError]' started.

But the testDeviceUserError test doesn't seem to complete. It just hangs there.

I'm not sure if this is something I've done wrong or if it's an Xcode 14 thing or something else?

The reducer for this action is very simple...

case .verifying(.deviceUserError):
	state = .login(.init())
	return .none

The testAnalytics test does not use a TCA TestStore and doesn't do anything touching TCA and seems to complete fine. It's just this test causing issues.

I wonder if this is because the AppFeature.State is an enum.

And so I'm changing the ACTUAL state rather than changing a property on state?

i.e.

Instead of ...

state.property = value

I'm doing...

state = value

?

If you pause execution while the test is hanging is there anything in the stack trace that tells you what is going on?

This is shown when I do that...

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x00000001ae507fcc in mach_msg_trap ()
#1	0x00000001ae508430 in mach_msg ()
#2	0x00000001042ac8ac in __CFRunLoopServiceMachPort ()
#3	0x00000001042a6ff4 in __CFRunLoopRun ()
#4	0x00000001042a675c in CFRunLoopRunSpecific ()
#5	0x000000012c925314 in -[XCTWaiter waitForExpectations:timeout:enforceOrder:] ()
#6	0x000000012c92703c in +[XCTWaiter waitForExpectations:timeout:enforceOrder:] ()
#7	0x000000012c9453e8 in +[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:] ()
#8	0x000000012c9458d0 in +[XCTFailableInvocation invokeInvocation:withTestMethodConvention:lastObservedErrorIssue:] ()
#9	0x000000012c945bc8 in +[XCTFailableInvocation invokeInvocation:lastObservedErrorIssue:] ()
#10	0x000000012c935ee4 in __24-[XCTestCase invokeTest]_block_invoke.78 ()
#11	0x000000012c9068cc in -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] ()
#12	0x000000012c935b2c in -[XCTestCase invokeTest] ()
#13	0x000000012c936f64 in __26-[XCTestCase performTest:]_block_invoke.119 ()
#14	0x000000012c9068cc in -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] ()
#15	0x000000012c936ad4 in __26-[XCTestCase performTest:]_block_invoke.110 ()
#16	0x000000012c91fa60 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
#17	0x000000012c91f98c in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
#18	0x000000012c9367a0 in -[XCTestCase performTest:] ()
#19	0x000000012c8f6a78 in -[XCTest runTest] ()
#20	0x000000012c922300 in -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] ()
#21	0x000000012c9221e4 in __27-[XCTestSuite performTest:]_block_invoke ()
#22	0x000000012c921cf8 in __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke ()
#23	0x000000012c91fa60 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
#24	0x000000012c91f98c in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
#25	0x000000012c921ca0 in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
#26	0x000000012c921f10 in -[XCTestSuite performTest:] ()
#27	0x000000012c8f6a78 in -[XCTest runTest] ()
#28	0x000000012c922300 in -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] ()
#29	0x000000012c9221e4 in __27-[XCTestSuite performTest:]_block_invoke ()
#30	0x000000012c921cf8 in __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke ()
#31	0x000000012c91fa60 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
#32	0x000000012c91f98c in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
#33	0x000000012c921ca0 in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
#34	0x000000012c921f10 in -[XCTestSuite performTest:] ()
#35	0x000000012c8f6a78 in -[XCTest runTest] ()
#36	0x000000012c922300 in -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] ()
#37	0x000000012c9221e4 in __27-[XCTestSuite performTest:]_block_invoke ()
#38	0x000000012c921cf8 in __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke ()
#39	0x000000012c91fa60 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
#40	0x000000012c91f98c in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
#41	0x000000012c921ca0 in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
#42	0x000000012c921f10 in -[XCTestSuite performTest:] ()
#43	0x000000012c8f6a78 in -[XCTest runTest] ()
#44	0x000000012c8f82ec in __89-[XCTTestRunSession executeTestsWithIdentifiers:skippingTestsWithIdentifiers:completion:]_block_invoke ()
#45	0x000000012c91fa60 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
#46	0x000000012c91f98c in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
#47	0x000000012c8f81e8 in -[XCTTestRunSession executeTestsWithIdentifiers:skippingTestsWithIdentifiers:completion:] ()
#48	0x000000012c9519d0 in __72-[XCTExecutionWorker enqueueTestIdentifiersToRun:testIdentifiersToSkip:]_block_invoke_2 ()
#49	0x000000012c951af0 in -[XCTExecutionWorker runWithError:] ()
#50	0x000000012c91cf90 in __25-[XCTestDriver _runTests]_block_invoke.184 ()
#51	0x000000012c900224 in -[XCTestObservationCenter _observeTestExecutionForBlock:] ()
#52	0x000000012c91cc2c in -[XCTestDriver _runTests] ()
#53	0x000000012c8f6f60 in _XCTestMain ()
#54	0x0000000102da88e4 in main ()
#55	0x0000000102fe5fa0 in start_sim ()
#56	0x00000001030b508c in start ()

Just reading through to see if there's anything I recognise.

Looks like there is an expectation holding things up. The TestStore doesn't use any expectations so that's strange. Are you able to find a repro that you can share so we can run locally?

Sure, I'll give that a go. Also... aware that I may be on an old branch so I'll update first and give that a try.

OK... so resetting the package caches seems to have sorted it. I think the protocol-beta branch I was on was a couple weeks old.

Although... maybe I shouldn't have done that now because now we won't be able to find the issue whatever is was.

Ah, well glad it's fixed now! If you ever track down what what SHA you were on before when the problem existed I would be curious to check out the diff of the protocol-beta branch just to see what was going on.

According to the Package.resolved it shows...

"branch" : "protocol-beta",
"revision" : "3bc12a37316f6549044e6ce3a2ae1ce151221f2f"

As the old revision.