groue/CombineExpectations

Expect recorder to not emit a value

Closed this issue · 2 comments

I'm trying to figure out the best way to cover a scenario where I expect a publisher to not to emit a value.

This does not work work because the internal XCTest expectation will mark the test as failed

receivedMessage = try? QuickSpec.current.wait(for: recorder.next(), timeout: 0.1)

The best solution I've found so far is to wrap the line in XCTExpectFailure as following

XCTExpectFailure("this should time out", options: XCTExpectedFailure.Options()) {
    receivedMessage = try? QuickSpec.current.wait(for: recorder.next(), timeout: 0.1)
 }

It still creates this gray "warning" I'd ideally like to get rid of, but I can live with it.
Screenshot 2022-03-01 at 14 44 21

Any opinions on this?

groue commented

Hello @petrpavlik,

Some expectations have an inverted modifier, and you may be well be after next().inverted of prefix(1).inverted.

Ah, I did read through that but somehow missed this part. Thanks! closing this