vscode-swift icon indicating copy to clipboard operation
vscode-swift copied to clipboard

Show diff output for failed `XCTAssertEqual` calls

Open ahoppen opened this issue 2 years ago • 2 comments

When an XCTAssertEqual fails, it would be great if we could see a diff of the actual vs expected output. That would make spotting the actual difference a lot easier.

ahoppen avatar Dec 05 '23 17:12 ahoppen

It's doing it for me Screenshot 2023-12-05 at 17 57 32

adam-fowler avatar Dec 05 '23 17:12 adam-fowler

Oh, sorry, I should have been clearer. It would be nice if the extension could show an actual diff between the expected and the actual value.

For example for

XCTAssertEqual("hello world", "hello, world")

It would be nice if the extension could open a diff view that highlights the ,. Or, even simpler if it reformatted the output to multiple lines.

XCTAssertEqual failed: 
+ hello world
- hello, world

For context, the sourcekit-lsp repo has a number of test cases where we are comparing arrays with multiple elements and if these tests fail, I usually take the XCTAssertEqual output and format it on two lines like above to determine where the actual difference is.

ahoppen avatar Dec 05 '23 23:12 ahoppen