bneumann / CppUTest-Test-Adapter

A test adapter for Visual Studio Code for the C/C++ Unit Test framework CppUTest.
MIT License
16 stars 7 forks source link

How to setup on VSCode #26

Open MohammedUbaid-eaton opened 2 years ago

MohammedUbaid-eaton commented 2 years ago

Hi,

I installed CppUTest on vscode & also installed dependency Test UI Explorer

image

I do not understand how to get started.

I have a .cpp file on which i need to run unit tests,

Kindly guide.

bneumann commented 2 years ago

Hi, you first need to set up the paths in the settings as described here: https://github.com/bneumann/CppUTest-Test-Adapter#setup

After you set the test executable path the plugin will automatically detect the tests inside it and show the in the test explorer

steverb1 commented 4 months ago

I'm not clear what is meant by "test executable". What kind of file would that be? (.exe or something else?). Is this a file CppUTest provides? I'm on a Mac, just trying to run the tests from James Grenning's book. I can run them from the command line, but see no tests in VS Code.

bneumann commented 4 months ago

Well if you compile your test code you should get an executable (i guess the one you are running?). That is your test executable. If you set it in the paths of this extension it should be used to identify your tests.

steverb1 commented 4 months ago

OK, thanks, I found the executable, and have settings.json correctly configured now. Still no tests showing up in the Test Explorer. Any ideas about what else might be wrong?

bneumann commented 4 months ago

You are completely right, I just tried it again (after years to be honest) and it didn't work. I will look into it

bneumann commented 4 months ago

Okay I found the culprit and will release a new version today evening. Funny enough I think not a lot people are using this extension because you could actually add multiple files likes so "cpputestTestAdapter.testExecutable": "test1.exe;test2.exe" but not like this "cpputestTestAdapter.testExecutable": "test1.exe" I never wrote tests (shame on me) for the settings parser, so one of the last PRs got through breaking the default behaviour. Thanks for adressing this issue

steverb1 commented 4 months ago

Thank you very much for finding the problem! Looking forward to the fix in the new version.

bneumann commented 4 months ago

No problem, i am a bit short on time recently (like in the past 2 years I guess). So it always takes some time to get things done. I just uploaded the latest version 1.3.1. Let me know if it works now

steverb1 commented 4 months ago

OK, that is definitely an improvement. I'm seeing things in the test explorer for the first time. However, I'm now getting an ERROR_LOADING_TESTS

Here is what I have in settings.json: "cpputestTestAdapter.testExecutable": "${workspaceFolder}/t0/t0_tests", "cpputestTestAdapter.testExecutablePath": "${workspaceFolder}/t0"

steverb1 commented 4 months ago

Screenshot 2024-04-17 at 09 50 19

steverb1 commented 4 months ago

That double quote character at the end looks suspicious. Would that still be something going on with the parser?

bneumann commented 4 months ago

That is odd, this text is loaded from the executable name itself. it worked with my local test executable file. Is the log showing anything helpful? I will check the commits if i fat fingered something in the code :)

steverb1 commented 4 months ago

Any update on this? And sorry, I just noticed you aksed if the log is showing anything. Where would I find that?

msoleck commented 1 month ago

I have similar problems with this issue.

Here is the software I am running:

I previously had the ERROR LOADING TESTS error, but I resolved that by pointing to the correct executable.

I now get this other weird message: image

I get a similar "error" message when i run it from the terminal image

Here is the result in the output window image

When I run the executable without the parameters, here is the output: image

My belief is that the tool tries to run the executable with some parameters.

My question is: does the this tool add some parameters which I am not aware?

Thank you for any help you can provide