Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running tests from within Visual Studio in a static lib project #275

Closed
refaelsh opened this issue Aug 17, 2019 · 8 comments
Closed

Running tests from within Visual Studio in a static lib project #275

refaelsh opened this issue Aug 17, 2019 · 8 comments

Comments

@refaelsh
Copy link

I am currently using Google Test. I can happily run my tests from within Visual Studio.
I want to start using doctest because the features list says I can use it along side my production code (Google Test cant do it). I have a static lib project in Visua Studio, and I want to run the tests from within Visual Studio. Here is what happens when I click the Test circle thingy (red rectangle in the screenshot) and choose Run. Green rectangle is my static lib project. Blue rectangle is my exe project.

Please help me :-) What am I missing?

@onqtam
Copy link
Member

onqtam commented Aug 18, 2019

Hi!

I see that you are using ReSharper. They recently added support for doctest, and I suppose that's what you are testing out. Unfortunately I haven't used ReSharper and haven't tested the integration - I'm not at all familiar with the interface and the mode of running/execution.

You should perhaps take this question to them, as I won't be able to look into this any time soon...

@refaelsh
Copy link
Author

refaelsh commented Aug 18, 2019

I understand what you are saying. I turned off ReSharper, but now my test is not being discovered by Visual Studio's build in Test Explorer thingy. Here is a screenshot.
Please help me discover what am I missing here?

@onqtam
Copy link
Member

onqtam commented Aug 18, 2019

I haven't used ReSharper and am not familiar with its interface... If someone else has any experience perhaps they could help with this. Otherwise you could look into the documentation of ReSharper or their support.

@refaelsh
Copy link
Author

You don't under stand, I turned off ReSharper. Could you please read my last post above?

@onqtam
Copy link
Member

onqtam commented Aug 18, 2019

Sorry I missed that - I'm just about to go to bed.

So... I haven't used the Test Explorer either, but I don't think there is any integration with doctest on the Visual Studio side... ReSharper is the first IDE/tool which integrated doctest in it's test discovery/runner - hopefully others will follow (perhaps I should contact someone for that...). You could still execute the tests by running the compiled binary. This is all I have for now, good night :)

@refaelsh
Copy link
Author

Good night and sweet dreams! :-)

For the morning: I understand now, there is no integration between doctest and Visual Studio (somebody needs to write a thingy called Test Adapter).

Regarding this:

execute the tests by running the compiled binary

Am I to understand from this that the usual and/or normal and/or best and/or optimal way of using doctest is to run my binary? Every time I need to see if my test passes or not? There is no way to run the test from within Visual Studio (ReSharper excluded)?

@refaelsh
Copy link
Author

Solved. Please read here, especially the Configuring test runner part. In case the link will not work in the future, here is an exert that helped me:

Configuring test runner
Unit test execution variables, such as command, its arguments, working directory, and environment variables are normally specified in project properties (Project Properties | Configuration Properties | Debugging) and ReSharper will take them from there.
However, if these properties are not specified there (for example, in a library project, in an 'Open Folder' or CMake project), you can define execution settings on the Tools | Unit Testing | Test Frameworks | C++ Tests page of ReSharper options (Alt+R,,O).
You can also use the Merge environment flag on that page. If it is selected, ReSharper will add environment variables specified in the Environment field to the environment variables from Visual Studio. If it is not selected, only environment variables from Visual Studio will be used.

@refaelsh
Copy link
Author

Thank @onqtam very much, your answers helped me to figure out the proper keywords for Google search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants