Dotcover does not resolve dependencies when Resharper does - resharper

I have a seperate MSTest project that runs tests against two other c# projects within the same solution. The tests are all MSTests and run succesfully in both the Visual Studio Test Explorer and Resharper (with MSTest set). Both are using my *.testsettings file that specifies the dependencies. Trying to get dotCover to generate coverage results gives me a FileNotFoundException on both the ddls from the referenced projects. This is similar to the exception I got with VS Test Explorer before adding dependencies in the testsettings file. Both dotCover and Resharper have the same test settings in options. Any ideas why dotCover cannot resolve the dependencies when Resharper can?

I've come across the same problem and had to do the following to get Resharper running dotCover again correctly for my solution:
Delete the resharper cache for your solution. It will be located something like :
%LOCALAPPDATA%\JetBrains\Transient\ReSharperPlatformVs14\v09\SolutionCaches\{folder with solution name in it}
Numbers may be different based on which version of Resharper you have (I have 2017.2 Ultimate).
Delete the visual studio solution cache:
{solutionfolder}\.vs\{solutionname}\v14\*.suo
Again, numbers depend on which version of visual studio you have (I have VS2015)
Finally, you may have to give a hint in the test project files to run the correct version of the .net framework. Insert the following into the <configuration> node of your app.config file in your test project(s):
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
Again, your supported runtime depends on which version of the .net framework your project is configured to use (in my case, .net 4.5.2).

Related

NUnit Test Adapter 2 assembly not found

I'm facing with a strange issue with Visual Studio 2012 Update 5.
I have to add Unit tests to an existing project and I have installed NUnit 2 Test Adapter via Tools->Extension Manager.
The intallation works fine and Visual studio is restarted but I cannot find the NUnit assembly to add to my test project.
Where I'm wrong?
Thanks
The adapter is... well, an adapter... It allows you to run NUnit tests within Visual Studio by making them look like tests that VS understands.
In order to write NUnit tests, you have to actually install NUnit. Probably, the simplest way to do that is to use the NUnit nuget package, which will install it into your test project and add the necessary reference.

Testing.Fakes Exception: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables

Test which use Microsoft Fakes Framework fail with exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables
VS solution and builds were originally created in VS 2012 and run fine under TFS 2012 build/ controller, but not under TFS 2013. I do have Ultimate VS 2012 and Ultimate VS 2013 installed on TFS 2013 build server. While troubleshooting this issue, I changed test setting in the build definition from using "Visual Studio Test Runner" to "MSTest.exe Test Runner (VS 2010 Compatible)", and now not able to change it back as "Visual Studio Test Runner" is no longer an option in the drop-down of choices. I even replaced build template in TFS 2013 with the one in TFS 2012 but "Visual Studio Test Runner" is still not an option in the drop-down of choices in the build definition Process\Automated Tests section while editing Test Run.
How to solve the problem and get the tests which use Microsoft Fakes to run in TFS 2013 build?
I was having this exact same problem and it turned out that I had a .testsettings file created in my solution and was telling the test runner in the IDE to use it. If you are getting this error in the Visual Studio IDE, verify that you do not have a .testsettings file specified by going under the Test menu -- if there is a .testsettings file specified with a checkmark next to it, click it to remove the checkmark. I suspect the presence of the .testsettings file causes Visual Studio to initialize the test runner differently.
If this is happening on the build server, verify that your build definition does not have a .testsettings file specified; ideally, perhaps remove the file altogether from source control and/or your solution. The presence of this file can trip up a TFS build.
I got the exact same error, but in my case it was a bug in ReSharper 2017.3.1:
https://youtrack.jetbrains.com/issue/RSRP-467796
Already fixed in ReSharper 2018.1

Debugging WatiN UI tests in Visual Studio 2012

I have a solution in Visual Studio 2010 that includes a test project that uses WatiN. It also has a test project with unit tests. Both use NUnit as the framework. I use Gallio to run/debug the tests.
I'm trying out Visual Studio 2012. My project builds fine. I can use the NUnit GUI to run both sets of tests. The Test Explorer lists all tests (unit and UI). I can run/debug the unit tests from within Visual Studio.
When I run the UI tests from within Visual Studio 2012 I get an error:
The CurrentThread needs to have it's ApartmentState set to
ApartmentState.STA to be able to automate Internet Explorer.
The error occurs on the following line in my TestFixtureSetup function:
browser = new IE(...);
I've Googled the error and seen plenty of suggestions about adding lines to the app.config. The odd thing is that I already have those lines.
<sectionGroup name="NUnit">
<section name="TestRunner"
type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
...
<NUnit>
<TestRunner>
<!-- Valid values are STA or MTA (Others are ignored) -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
Has anyone gotten WatiN working with the Test Explorer in Visual Studio 2012? Any suggestions for getting it to work? Are there known compatibility issues?
I also tried installing Gallio with the RC and it broke some things that required a bit of effort to fix. I would prefer to use the integrated Test Explorer.
Found a solution here.
I added the following to my AssemblyInfo.cs file:
[assembly: RequiresSTA]
Still outstanding is why doesn't the test runner see the STA settings in the app.config?

Invoke a publish from msbuild for visual studio 2012

For VS2010 and before I was utilizing Web Deployment Projects (WDP) to help package my website for production deployment. I had a MSBuild script that compiled the solution in release mode. An output of that was production ready website files compiled and cleaned by the WDP.
I see for 2012 WDP have been removed, and a new tab has been created in the properties for the web application. The options are the same, but now the invocation of this is done via the Publish option (before you just compiled in release mode).
So the question is this. From an MSBuild script, how do I invoke a Publish operation? I found some old posts that...
msbuild /target:publish
would do the trick. But that doesn't seem to work in 2012.
Also, I tried in my msbuild task...
<MSBuild Properties="Configuration=Publish;"
StopOnFirstFailure="true"
Projects="$(BuildDirectory)\MySolution.sln"></MSBuild>
...but msbuild just reported "unknown configuration".
How can I have msbuild run the publish option from the command line?
It appears that there are now some other options for publishing from the command-line. Specifically something along the lines of the following seems possible now with some RC updates to Visual Studio 2012.
msbuild mywap.csproj /p:DeployOnBuild=true;PublishProfile=MyProfileName
For more details check out this post by Scott Hanselman and check out the section on Publishing.
I wasn't able to get the publish to run, but looking at the output from Visual Studio I think I have found an alternate solution. Turns out the obj\Release\AspnetCompileMerge folder has a deployable and clean version of the project. It contains byte identical files to the final output folder.
I did have to change my msbuild script to include the DeployOnBuild option...
<MSBuild Properties="Configuration=Release;DeployOnBuild=True;"
StopOnFirstFailure="true"
Projects="$(BuildDirectory)\BigWave.ALL.sln"></MSBuild>

How do I integrate Machine.Specifications with ReSharper 6?

I'm using ReSharper 6 and I'm trying to get it to pick up my MSpec tests in the Resharper test runner. Unfortunately I can't seem to get this to work.
I have copied the MSpec dll files (Machine.Specifications.dll and Machine.Specifications.ReSharperRunner.5.1.dll) to the ReSharper plugin directory but it does not seem to find the plugin. When opening the test runner and refreshing no tests are picked up.
I do realize that the test runner plugin is for version 5.1 but ReSharper should at least find the tests in my solution, even if it is not able to run them using the 5.1 runner?
Any suggestions on how to get this to work?
The resharper team just post (July 20th, 2011) a solution about the integration of MSpec in Resharper 6.
Head over there
I don't use Machine.Specifications but I do know you won't be able to use a 5.x compiled plugin with 6.0 because the DLL's have changed a lot
You can run Visual Studio with "devenv.exe /ReSharper.Internal" flag to enable the internal debug menu in Resharper, that might give you a starting point if you were to download MSpec source and attempt to compile with the Resharper 6.0 DLL's

Resources