I have a longish test with several sections of this form:
let value = computationThatLogs()
XCTAssertEqual(value.a, 77)
I observe that the file:line:error
messages from violated XCTAsserts frequently get mixed into the debug messages of the computation in the next section, often even on the same line as a debug message!
Why is that? How can I prevent that from happening? fflush(stderr); fflush(stdout)
before every section does not seem to be enough.
In case that is relevant, the computations in each section are actually asynchronous; the test (i.e. the main thread) waits for them to complete using a DispatchSemaphore
.
I observe this in AppCode; can not reproduce with XCode.