I was not using my exact code in the first posting. The following is the crucial point:
When using
XCTAssertEqual(myFunction(), "the value")
and myFunction() does not return the desired value, then in the according error message I immediately get both values for a quick comparison, which is very nice.
But when using Swift Testing:
#expect(myFunction(), "the value")
I only get the error message "Expectation failed: myFunction() == "the value".
I have to add additional code to know what the wrong value is.
Is this something that could be changed, or is it an inherent disadvantage when using Swift Testing? How do you deal with it?
Not sure if this is just a typo, but use == rather than , if you are comparing them for equality.
If you're using Xcode, more information is available (including the values of the operands above) if you click the red test issue banner to expand it or if you look at the test report. For more information, take a look at Meet Swift Testing from WWDC24.
Not as far as I know. What version of Xcode are you using? And are you using Swift Testing as a package dependency? If so, Xcode's integration with Swift Testing is much more limited when you include it as a package dependency. Xcode 16.0 and later ship with Swift Testing built in, so you can use that built-in copy instead.