No Coverage Data for Tests in Current Context - visual-studio-2010

I'm using Visual Studio 2010 SP1. When I run "All Tests in Solution", I get code coverage results to show up just fine. However, when I run a subset of tests using "Tests in Current Context", I only see "Cannot find any coverage data (.coverage or .coveragexml) files. Check test run details for possible errors."
A Google search shows that others do get code coverage results when running a subset of tests. Is there a configuration I'm missing somewhere?

I think I figured out the reason for this, but it still doesn't make complete sense. If I run the tests in the current context by going to "Test -> Debug -> Tests in Current Context", it doesn't work (code coverage is not generated). However, if I do "Test -> Run -> Tests in Current Context", then it works. So far so good, it kind of makes sense that it would only work when not in Debug mode.
But the strange part is if I use the keyboard shortcut for "Test -> Run -> Tests in Current Context" (Ctrl-R, T), it does not work. So I have to run it from the menu instead of using the keyboard shortcut, otherwise it says no code coverage was generated.

Related

How can I re-run a unit test X-amount of times?

My problem is that my unit tests fails from time to time. Most of the times it is successful.
I would like to run it X amount of times or just repeat the test case until it fails.
What I can do is to just click on the test and rerun it once more even though it has been successful run, but that is time consuming.
I have had a look in Visual Studio in "Test Explorer" and Resharper "Unit Test Session", but I can find a smart way to rerun all test until it fails.
Is there another way?
Best Regards,
Hans
I see you mention you have ReSharper - in the Resharper unit test session window you can select the test you are interested in, then click the drop-down next to the Run button and there is a "Run Unit Tests Until Fail" option
Also, see here

How can I see the results of my Unit Tests in VS2017?

I'm running unit tests on my GetModelAsync() and CreateModelAsync() methods in VS17. I then run Assert.Equal checks on the model fields to ensure they match the expected values.
I want to be able to see the final state of my models, which will help me determine why a test is failing or allow me to manually check my models. I'm thinking something similar to tracking variables in the debugger would make sense, although I don't want to actually run the debugger.
Is there a way to do this?
You can write to the console in your tests and it will show up in Test Explorer. You may want to serialize complex objects to JSON first before doing this. For example:
Console.WriteLine(JsonConvert.SerializeObject(myObject));
Note, for Visual Studio's built in test runner, you have to go through a few steps to see the console output. In the Test Explorer window, click the name of your test, then in the results panel click the Output link, which will open a separate window to show the console output. It's all very unintuitive.

How do prevent "Debug Error!" window from appearing?

I have a series of Google Unit Tests that are launched via a bat file. Some of these tests are broken and a window appears when they run:
Microsoft Visual C++ Debug Library
Debug Error!
... Info about error
This window waits for a user to press Abort, Retry, Ignore. Of course, this halts my test. Currently, I delete the broken tests before I run the batch. I want a way to force this window to abort or ignore - so I don't need to skip the broken tests.
This problem is similar to; however, I cannot write to reg keys
How do I disable the 'Debug / Close Application' dialog on Windows Vista?
Update: My manager says this window might not appear if this project was in release. Trying to do that now. However, if there is a solution besides changing my project to release, I would appreciate it! :D
That's what you get from a failed assert() in the source code. Useful to debug the test. But actually running unit tests against code that was compiled in the Debug configuration is not useful. Your customer isn't going to run the Debug build either.
Only test the Release build, that disables those assert() calls as well.

User cannot see TFS2010 test results in VS2010

I have a few lists of tests that I setup for a project that builds to a website. I have a bunch of unit tests and integration tests that runs before deploying the site. I have one user that clicks on the failed build in Build explorer but the Test results(that I can see-all test) that appears below that is empty.
If I click on it I can see a complete list of tests that passed as well as the test that failed. In the "Test Results" window at the bottom there is a drop down list to choose the(it looks like environment??) and when they choose "System#SERVERNAME SERVERTIME" it does not show the list that I can see if I am logged in. It seems to be a permission issue but where?
Thank you
Jack

VS2010 code coverage not working

I've got a solution in VS2010 where I can't get the code coverage working, I always end up with the error
"Cannot find any coverage data (.coverage or .coveragexml) files. Check test run details for possible errors.
I did set up everything as usual, so in the test settings I enabled the "Code Coverage" checkbox on the "Data and Diagnostics" page and chose the dll to be tested. I also added the "Re-signing key file" as we sign our assemblies. I don't know any other thing that prevents me from getting the coverage info, manually comparing the "Local.testsettings" for this solution with files from other working solutions didn't show any problems.
Any ideas what the reason might be and how to get it working?
Thanks in advance
G.
Alright,
For some reason the Test Settings were changed from "Local (local.testsettings)" to "Trace and Test Impact (traceandtestimpact.testsettings)". Don't know why that happened, now it works again...

Resources