Automated tests on TFS 2010 using a test assembly file specification - unit-testing

I'm using TFS, it works fine. Now I want to add tests and code coverage. So I create a Local.testsettings. Running tests on my computer runs fine.
Configuration of the TFS Build is as follows:
- Automated test with test assembly file specification and the same test settings file (as recommended, instead of using a .vsmdi file)
When launching a build with TFS, my tests don't get executed :
Run MSTest for Test Assemblies
The MSTestActivity was invoked without a value for Platform or Flavor. The values Mixed Platforms and Debug were used.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe /nologo /usestderr /testSettings:"C:\Builds\1\MyProject\Sources\MyProject\Main\Source\MyProject\Local.testsettings" /searchpathroot:"C:\Builds\1\MyProject\Binaries" /resultsfileroot:"C:\Builds\1\MyProject\TestResults" /testcontainer:"C:\Builds\1\MyProject\Binaries\MyProject.Tests.Module1.dll" /maxpriority:"1" /minpriority:"1" /publish:"http://tfsserver:8080/tfs/Test" /publishbuild:"vstfs:///Build/Build/433" /teamproject:"MyProject" /platform:"Mixed Platforms" /flavor:"Debug"
Loading C:\Builds\1\MyProject\Sources\MyProject\Main\Source\MyProject\Local.testsettings...
Loading C:\Builds\1\MyProject\Binaries\MyProject.Tests.Module1.dll...
Starting execution...
No tests to execute.
There are no results to be published.
So it finds the assembly, but MSTest doesn't actually runs the tests.
Any hint is welcome.

Looking at this:
/maxpriority:"1" /minpriority:"1"
It looks like your priority criteria may be the problem.

Related

Visual Studio Test results file

I can't find the place where VS 2017 keeps the test result file. I have a lot of Specflow tests which are running fine but i want to find the place where VS is keeping the results. I am using a Library called Pickles which generates documentation from specflow, so it was be accessed via an HTML page. This library needs the VS test results file to add info about which tests are passing etc.
Since SpecFlow is just generating unit tests under the hood, if you run those tests from visual studio 2017 it does not generate test result files.
Instead, you need to use the vstest.console.exe command line interface to run the tests.

Using Visual Studio to do Code Coverage on gtest unit tests for native VS C++

Friends,
I have been looking at unit test code coverage tools for the last 2 weeks, evaluating them for our specific needs. The last one I would like to evaluate is Visual Studio's own code coverage for native C++ unit tests. In our solution, we have the following:
full Visual Studio 2013 development environment with large projects
of multi-100 k lines of code
900+ unit tests already written in GTEST (working and executing in
the build process) and working in this environment native C++ code
(unmanaged)
a dozen projects in the solution or so
What I am trying to do is figure out
If I can use the Visual Studio code coverage Analysis tool to report results on my gtest unit tests
get code coverage results generated each time the unit tests or run (our unit tests are automatically run in a post-build step)
I have looked around these forums, MSDN and other sites (like stackoverflow) and I can't find a good source of guidance to making this combination of tools work. As I say, I have the solution, projects and unit tests running and working well, but to add code coverage I am not seeing how to do so using Microsoft's own Visual Studio code coverage.
I have already evaluated a few other packages like Software Verify, Semantic Designs, OpenCPPCoverage and Bullseye. I was hoping to try our Visual Studio's code coverage component since it is already part of our dev environment, but I can't seem to figure out how or if that will work.
Any help?
Thanks for any feedback, info you can give.
After searching more, I found that what I was missing was an adapter to run the tests in VS 2013. While my tests were executing as part of the build process, they weren't generating results in the Test Explorer because it wasn't being interfaced with Visual Studio's test explorer. This can be done simply by installing an extension. The extension I found that works well for us is GoogleTest Runner, which is found in the extensions library here:
GoogleTest Runner
I am leaving this question and answer here in case others have this same issue and need some help

How to get Visual Studio Online test runner to run my specflow tests?

I have a project which builds and runs tests in Visual Studio Online. I recently added SpecFlow the the project and wrote a bunch of scenarios, some of which run against a LocalDb database. I was half expecting the tests to fail on VSO, but when I pushed the code up it ran all of my tests and they all passed. When I checked the logs it seems that my Specflow tests were not run.
Is there something I have to do to get the specflow custom tool which generates the actual unit tests to run as part of the build, so that VSO will find the tests after it has built?
Can I run what are effectively integration tests in VSO, creating and destroying databases in my tests?
Ok so this was a bit of a D'oh moment. VSOnline wasn't running my tests because Specflow was building NUnit test. Changing it to build MSTest tests meant that the generated files containing the tests had the correct attributes and VSOnline recognized them and so happily built and ran them.
And using the LocalDb during the tests was fine as well, all worked like a dream.

Visual Studio 2012 C++ code coverage merge executables

My c++ unit tests use gtest framework so every test is a separate executable. I'm running the CodeCoverage.exe tool to get the raw coverage data of each executable run. When I open the results in Visual Studio, each executable run appears in a separate branch and the results can't be merged together.
Is there any way to make this work?
One thing I've tried is to specify /session:uniq in the command line for both runs but that didn't have any effect.
Does it help you to capture via vsperfcmd.exe?
Build your gtest with /profile flag specified to the linker
Instrument your gtest exe with Visual Studio coverage instrumentation
vsinstr.exe gtest.exe /COVERAGE
Launch the code coverage capture tool
vsperfmon.exe /COVERAGE /OUTPUT:gtest.coverage
Run the gtest
Stop the capture tool
vsperfcmd.exe -shutdown
Launch the output file (gtest.coverage) to see the output in Visual Studio
OK, this should have been a comment, but I don't have the permissions yet.
You can run all your unit tests with the macro:
RUN_ALL_TESTS();

How can I disable code coverage / assembly instrumentation in Visual Studio 2012?

I have a project upgraded from Visual Studio 2010 to 2012 and the .testrunconfig file was included in the upgrade process.
I noticed that it was possible to click "Analyze code coverage" on any of the unit tests that I had run and it would correctly display the result. However, my test run configuration (originally from VS 2010) had code coverage disabled.
After doing a bit of research I learned that the VS 2010 configuration files have been deprecated and replaced by .runsettings files. It would appear that VS 2012 enforces assembly instrumentation by default which has a massive overhead associated with it.
Therefore, I would like to know how I can disable code coverage in VS 2012. Based upon my current findings it does not seem to be a trival task. One recent article I read had me creating an XML file manually and naming it "MYCONFIGURATION.runsettings" and manually manipulating XML attribute values.
Does anyone know how this should be done?
This is what I understand from your post:
You have a Test project with .testsettings file. You have not enabled code coverage in the test settings.
Code coverage instrumentation is not enabled by default in your scenario. Binaries will be instrumented if you do 'analyze code coverage' from VS.
Additional Info:
You can confirm that .coverage file is not generated by running the following command from visual studio developer command prompt:
vstest.console.exe /Settings:<your test settings file> test.dll
A coverage file will only get generated if you have enabled coverage in test settings.
Code coverage is only enabled through the Test Explorer using data driven adapters. The metadata for tests ran through the test explorer is almost completely different than that of tests ran straight from the unit test session window. Have you tried simply running it straight from the code (the MSTest gui bubbles) or from the unit test session window?