Typemock not integrating with VS2017 and NUnit3 - visual-studio-2017

Trying to debug tests that use TypeMock and I get the following error:
TypeMock.TypeMockException: '
*** Typemock Isolator is currently disabled. Enable using the following:
* Within Visual Studio:
- Use Typemock Smart Runner
- For other runners, Choose Typemock Menu and click "Integrate with Other Runners"
* To run Typemock Isolator as part of an automated process you can:
- run tests via TMockRunner.exe command line tool
- use 'TypeMockStart' tasks for MSBuild or NAnt
For more information consult the documentation (see 'Running Unit Tests in an Automated Build')'
"Integrate with other Runners" is selected.
Versions:
Visual Studio: 15.9.4
TypeMock: 8.6.5.1
NUnit: 3.7.1
Installing the latest versions of TypeMock and NUnit does not fix the issue.
Edit: it works fine when I 'run' the tests. It only fails in 'debug'.

The solution to this problem (as provided by Typemock Support) was as follows.
Create a file named knownRunners.dat in C:\Program Files (x86)\Typemock\Isolator\8.6 (Typemock remarked that this might not be the location of my Typemock 8.6 installation - so it would be best to confirm.) The contents of the file should be:
testhost.x86.exe
testhost.exe
After doing this I restarted Visual Studio, and I could debug tests without any issues.
EDIT (2021-03-08)
In at least Typemock 8.2.3 this issue became intermittent. Updating the contents of knownRunners.dat to the following should resolve any issues:
testhost.net48.x86.exe
I found version 8.9.3.1 to work without any issues.

My name is Coral, and I work for Typemock.
I noticed by chance your post here and I'd like to help you :)
Do you mind answering the following questions, please:
• What runner are you using to run your tests?
• Do you use other tools as well (e.g dotCover, Coverage)?
Additionally, I'd appreciate it if you could run following task for me:
Go to Typemock->Options->Mocking Integration and check that "Enable Mocking integration" and
"Enable Auto Linking(with other Coverage Tools)" boxes are checked too.
Then, Open Developer Command Prompt for VS2017 as an admin
- Run the command: devenv /Setup
- Wait until it finishes
- Open your solution
Try to debug your tests now and please let me know if this solves the issue.
It would be helpful if you could send us the logs directly to the following e-mail address: support#typemock.com
You can retrieve the logs via (Typemock->Options->Logs-> Mocking ( check SmartRunner as well if you are running via SmartRunner)
I hope this helps. In the future, feel free to open a ticket at Typemock support:
https://typemock.freshdesk.com/support/tickets/new

Related

Guidance for running tests using MSTest v1 in Visual Studio 2017 15.8.1

I upgraded to Visual Studio 2017 last week. A solution with several test projects using MSTest v1 seemed to be fine at first. Most test projects execute tests fine. This is .NET Framework, not .NET Core.
However, there is one project where I am encountering issues. It's an integration test project, meaning it runs web application tests using the ChromeDriver and Selenium. This project references NUnit, though that reference comes from another project reference. I am not actually using NUnit as my test framework.
This is the error when trying to run any test in that particular test project:
Could not find test executor with URI 'executor://mstestadapter/v1'. Make sure that the test executor is installed and supports .net runtime version .
Test project {name} does not reference any .NET NuGet adapter. Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
Disabling the option indicated below made everything work:
I found this solution after browsing the preview release notes at https://learn.microsoft.com/en-us/visualstudio/releasenotes/vs2017-preview-relnotes#--visual-studio-2017-version-158-preview-4 (scroll down to "... What's New ..." and then .NET Test Adapter Extension). It mentions this breaking change (though it didn't break my other projects), but there is no mention of what to actually do to solve the problem.
Of course, long-term, keeping that option unchecked doesn't seem feasible. So I am looking for guidance on how to proceed.
I already tried to see if I could "quickly" upgrade to MSTest v2, but that had an issue because System.Runtime 4.1.2 couldn't be found. I tried adding System.Runtime 4.3.0 via NuGet, but that didn't solve the issue.
I was getting a similar issue running Xamarin.UITests and resolved it by installing the "NUnit 2 Test Adapter" Extension in Visual Studio. In Visual Studio 2017 you do this from Tools > > Extensions and Updates... > Online > Search "NUnit Adapter" > click the NUnit 2 Test Adapter then the Download button to install. Restart Visual Studio when prompted to complete the installation.
It would be interesting to understand how the MSTest V1 framework assembly(Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll) is referenced in this project. The compatibility checkbox that also ended up being disabled in the image above should ensure that this project has MSTestV1 tests and enabled run tests. If it isn't then for some reason the detection logic is busted and needs to be fixed - a snippet on how the assembly is referenced would be helpful there.
As for moving to MSTest V2, this blog should help: https://blogs.msdn.microsoft.com/devops/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/ . And for the specific issue you seem to be running into, this github issue on the repo sounds similar: https://github.com/Microsoft/testfx/issues/184 .
Caltor's answer pretty much solved it for me: it was the NUnit Adapter I needed. But I followed slightly different steps. Here they are for VS 2019 (but probably apply to VS 17 too):
Right clicked on the References node under my project in the solution explorer
Chose "Manager NuGet packages"
Clicked Browse
Searched for nunit3testadapter
Hit install on the result that popped up
The issue for me was similar to the OP's - the adapter was installed on some projects but not others. But confusingly this wasn't immediately visible under the "References" node for that project. The only node relating to nunit under that References node said "nunit.framework". So the references for test with and without the adapter looked the same.
"... but that had an issue because System.Runtime 4.1.2 couldn't be found."
I think this is a setting in the app.config that does not get updated when the project settings are updated. I searched for System.Runtime under the packages folder and then changed my app.config to match what I found, and then that particular problem went away.

NUnit3 throws exception System.Runtime, Version=4.2.0.0 not found while trying to run test in NUnit3 console

Environment:
.Net Core 2.0
visual Studio Professional 2017
NUnit3
OpenCover (For code coverage)
ReportGenerator(For code coverage report)
Hi Nunit Team,
I am pretty familiar with MS Test framework and have worked on that extensively but was testing how suitable NUnit framework would be and so wanted to do a small POC around that. I created a small classlibrary and a unit test project. Below are the NuGet package been installed:
NUnit 3.7.1
But when I try to run the test cases from console runner like below I get exception saying System.Runtime, Version=4.2.0.0 assembly not found.
C:\Users\UN\.nuget\packages\nunit.consolerunner\3.8.0\tools>nunit3-console.exe D:\Code_Trials\BoMLibrary\BomTest\bin\Debug\netcoreapp2.0\BomTest.dll
Exception detail:
Errors, Failures and Warnings
Invalid : D:\Code_Trials\BoMLibrary\BomTest\bin\Debug\netcoreapp2.0\BomTest.dll
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
----> Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Settings
DisposeRunners: True
WorkDirectory: C:\Users\Smukherjee.nuget\packages\nunit.consolerunner\3.8.0\tools
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETCoreApp,Version=v2.0
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 4
Am really not sure why so? No matter what I try not able to pass through this error. Moreover, when I try to install the assembly from Nuget I don't even find a assembly with version 4.2.0.0.
Tried installing the version 4.3.0.0 of System.Runtime but no luck. Can you please help on this.
Strange thing, I have got a sample unit test project (as part of opencover nuget install) which targets .Net Framework 4.5 and have NUnit2.6.7 package installed and when I try to run that using NUnit3 console it works like charm.
Even, installing NUnit3 latest stable version 3.10.1.0 doesn't help either. Also, it's surely not an Opencover issue since opencover console just passes the test run request to NUnit console. So the issue has to be around NUnit.
Let me know if you need more information around this.
Found the answer to this here https://github.com/nunit/nunit/issues/2763
NUnit Console doesn't run .NET Core tests - you need to use dotnet test instead. Take a look at this page:
https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard

NCover not finding unit tests

I am trying to install NCover in an existing C# .NET project for work. Unfortunately, after I download NCover and installed the Visual Studio extension, it wasn't finding any of the unit tests. The answers I've seen/heard seem to be in the vain of 'It wasn't working...time passed...it started working.'
I can run the tests with Visual Studio's Test Explorer, but I need to get NCover installed to see the code coverage. I had NCover installed previously, and other people on my team are getting it to work within the same project.
I am using Visual Studio 2013 with the newest version of NCover Desktop (v 5.1).
I am getting two errors in the console log.
The first switches between saying:
Agent Error (v4x64): An error occurred while loading assembly
and
Agent Error (v4x64): There was a problem loading test assembly [test path]. Could not get bytes from loader AppDomain
The second (after I try to run NCover) says it 'Could not load config' for the test dll.
I copied the 4 XML config file (Bolt.ext.config, Bolt.Extension2008.dll.config, NCover.exe.config, ncover.axplorer.exe.config) from one of my team members, so I'm pretty sure that I have my config correct.
Has anyone else experience this/have any suggestions? Help would be greatly appreciated!
Further information:
When I hover over the grayed out test dll in the bolt test panel, I get the following error:
Assembly is not loaded. Select and run to build and load this assembly
I was looking at this post, but it doesn't seem like any of the solutions are working for me...
After working with some of the other developers in my office, we discovered the issue was with the NCover version. For our tests to run, we needed to use NCover v5.0. Neither v5.1 or v5.2 would work with our setup. Not sure what changed in v5.1 that wouldn't let it find the tests, but I'm glad it's working now :)

Run xUnit tests from TFS2010

I'm trying to work out how to run xUnit tests from TFS 2010.
I found some articles on how to achieve that with the older version (http://jonnekats.wordpress.com/2009/05/07/integrate-xunit-tests-into-your-daily-team-build/, http://weblogs.asp.net/mehfuzh/archive/2009/08/25/configuring-team-build-using-xunit.aspx).
These approaches don't work anymore with TFS 2010 because builds are no longer MSBuild files but instead are Workflows with different tasks.
What I would like to achieve is something similar to what I've got on my dev machine:
- build everything
- run the .xunit project file
- check the results
All that I can see on the web are custom build steps which I can't/won't use because I'll have to configure them for each single unit test assembly and they'll probably get completely messed up in TFS.
Any input would be appreciated.
Why dont use "InvokeProcess" in TFS Build workflow and invoke xUnit command line interface with the necessary xUnit project files as parameters?
You can capture the output of the command line by setting InvokeProcess->stdout to write a build message.
Take a look at the xUnit work item Support VSTS Test Runner on codeplex. You can find there a VS2010 extension in Beta version.

Running VSTS tests without mstest.exe

From reasons I won't get into, all our unit tests are using the VSTS test framework. I now want to create an MSBuild script that runs the tests, but I don't want to use mstest.exe from various reasons (it's slower, requires Visual Studio installation everywhere, I need to maintain testrunconfig, etc.)
I've seen that TestDriven.net and TeamCity are able to run VSTS tests 'NUnit style', without using mstest.exe. Are you aware of any standalone command line utility that does this?
You can execute Team System Tests (MSTest) in NUnit if you use a special NUnit Addin that recognizes the MS Test Attributes (TestClass, etc).
Exact Magic Software has an open-source "test-adapter" that can do this.
UPDATE: I've reworked Exact Magic's Msts NUnit Adapter for NUnit 2.5.2.
Download here: http://snippetware.googlecode.com/files/ExactMagic.MstsAdapter.zip
Read more about it here: http://www.bryancook.net/2009/10/mstest-nunit-adapter.html
It seems like TeamCity is simply leveraging Gallio to run VS tests. Gallio appears to have msbuild integration and sounds perfect but after a closer look it seems that it would require a VS install just like MSTest as it appears to depend on MS exes:
The plugin enable condition was not satisfied: '${process:DEVENV.EXE} or
${process:VSTESTHOST.EXE} or
${process:QTAGENT.EXE} or
${process:QTAGENT32.EXE} or
${process:QTDCAGENT.EXE} or
${process:QTDCAGENT32.EXE}'.
Host process exited with code: 0
That being said it sounds like at least one person has got it working:
Christoph De Baene - Running MSTest without Visual Studio
It is possible to run MSTests without installing Visual Studio. See how-do-i-use-mstest-without-visual-studio.
I did this so that I could run my tests as part of my CI process. (I am using CC.NET for my CI solution).
I am in a similar situation as you, in that I want to use TestDriven.NET to get code coverage stats. But, I am running into problems. My first problem is that I am using AssemblyInitialize attributes to initialize a database connection. This isn't supported by NUnit so about half of my tests fail whereas they run fine under MSTest.
So, it seems that translating tests from one test framework to another has pitfalls. If you are aware of that, then go forth, but it might be better to try and keep consistent on one test framework.
We run VSTS tests using msbuild TestToolsTask on a Cruise Control server. This does not use the MSTEST executable -- the condition you ask for -- but does use a variety of TFS dependencies.
Note that we are migrating tests off of the VSTS test framework for NUnit, mostly because we can create extensions for NUnit to perform useful tasks.