DavidSchuldenfrei / gtest-adapter

Other
18 stars 9 forks source link

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

Closed ftrofin closed 6 years ago

ftrofin commented 6 years ago

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.

DavidSchuldenfrei commented 6 years ago

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)

ftrofin commented 6 years ago

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).

DavidSchuldenfrei commented 6 years ago

@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.

ftrofin commented 5 years ago

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

DavidSchuldenfrei commented 5 years ago

Glad to hear that. Thanks