DavidSchuldenfrei/gtest-adapter

Feature request: Cmd+Clicking on the file location reported by the failed test assertion should navigate to the code

Closed this issue · 5 comments

I noticed that if a test assertion fails, it is reported in the output like this:

/Projects/unittests/utestExamples.h:59: Failure
Value of: false
  Actual: false
Expected: true

And indeed, at that location there is a test assertion that failed. When I compile with VS Code (also using tasks) and compile errors are reported in the integrated output console, I can Cmd-click on the errors and it takes me straight to the source. I think this should possible here too but it is not enabled. It would be very helpful and a great time saver if this was enabled when running the tests.

I believe that what I need is a "Problem Matcher" for the output of Googletest. I will try to look into it.
Thanks for your suggestions (and your review)

Thank you for your hard work to support this plugin, it is very much appreciated!

What's interesting about this is that my build task doesn't have a special problem matcher, the build task entry looks like:

{
            "label": "Build unittester Debug",
            "type": "shell",
            "command": "xcodebuild -project ${workspaceRoot}/makeTests.mp.xcodeproj -scheme unittester.Debug build |xcpretty",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": []
        },

And the file link is automatically recognized although it is filtered through xcpretty. Here it is how the output looks like:
screen shot 2018-10-16 at 9 24 08 am

I wonder how VS Code recognizes that link automatically in that case. I hope there's some trick that you can leverage as well so you don't have to write a lot of code (maybe it's a setting somewhere).

@ftrofin "Problem Matcher" was not the correct approach.
VS Code automatically recognizes File Paths in the output window, but only if it is a full path. GoogleTest outputs a partial path, and the way it references the line number isn't VsCode compatible.
I reformat the output of VsCode on the fly now.
I believe that this should work in v 1.4.0
I have done limited testing on Non-Windows platform, so let me know if you still encounter issues.
As always thanks for the feedback, and if you have further suggestions, please let me know.

Thank you David for fixing this! I verified that it works nicely now.

Glad to hear that. Thanks