1

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.

Raphael
  • 9,779
  • 5
  • 63
  • 94
  • FWIW, when _debugging_ tests in AppCode 2019.1.1 (with XCode 10.2) the output order is as expected. In the absence of any breakpoints, the runtime overhead is so small that it's well worth getting comprehensible output. – Raphael May 03 '19 at 10:05

1 Answers1