I have a helper function that looks something like this:
private func test(state: State, against expectedState: State, sourceLocation: SourceLocation) {
// a bunch of irrelevant checks happening here
#expect(something == somethingElse, sourceLocation: SourceLocation)
}
Works like a charm. Great work! But:
XCTAssert & co have the #line and #file values that will set them with default values if you call them. This helps me finding the actual test that failed while calling a helper function in a unit test, instead of all of my tests failing inside of the helper function.
I tried using private func test(state: State, against expectedState: State, sourceLocation = SourceLocation()) {
but that only highlights the function definition line where I create the instance.
Even if #line
still seems to be around, there doesn't seem to be a way to create a SourceLocation
manually either.
Is this still work in progress or I simply missed something?
I do find references like sourceLocation: SourceLocation = #_sourceLocation
but that macro does not work for me.