Unit test .Net Framework 3.5 project in VS 2017 - unit-testing

I have some legacy projects with test libraries.
The projects (and unit tests) target .NET 3.5.
We are using VS 2017 enterprise.
I was able to locate some nuGet packages that would allow the tests to build correctly, but Test Explorer does not see the tests at all. I presume this is because there is no Test Adapter.
The packages I am using are:
Microsoft.UnitTestFramework.Extensions v1.0.0.3
Microsoft.VisualStudio.QualityTools.UnitTestFramework.Updated v15.0.26228
Most of the packages I found would not install due to a lack of .Net 3.5 support. Which makes some sense in 2017, but still.
Does anyone know what Test Adapter I can use to make legacy .Net 3.5 unit tests visible to VS 2017 Test Explorer?
Things I can't do:
use a different version of VS
re-target the libraries to a different framework version (they are for SharePoint 2010)
Rewrite all the tests for a different test framework (unless there's a very straight forward translation of the attributes/asserts I could do with find and replace, as there's a lot of tests)
Appreciate any tips!

Related

UWP Unit Tests Don't Show Up in Rider

I have a solution with two unit testing projects. One is for .NET and the other is for UWP. The .NET Framework and .NET Core tests show up in Rider but the UWP tests don't show up. They show up in Visual Studio. You can see the project here. It appears that dotCover is supposed to support UWP. I assume that Rider uses the same engine. Also, I opened dotCover and found my app unit testing app among the packages but it doesn't pick up any of the tests either. I'm using MS Test but can switch if need be.
This is what I see in dotCover:
Does Rider support UWP for unit testing? If not, can I do this with dotCover? What am I doing wrong?
Right now, even ReSharper does not support discovering UWP tests in Visual Studio 2019 due to a lack of API. That's why it does not work in Rider as well.
However, we've implemented our own test runner to run UWP tests https://youtrack.jetbrains.com/issue/RSRP-473827, and it will be available in upcoming releases in both ReSharper and Rider.

What is the easiest way to get TFS 2013 to run unit tests via VS 2015

We have Team Foundation Server 2013 installed with Visual Studio Professional 2015 and I've been able to get continuous integration builds working using the TfvcTemplate.12.xaml build process template and the "/tv:14.0" MSBuild argument. However, I can't seem to find a way to tell TFS to use the 2015 Unit Test suite.
This post Build VS 2015 Solution w/ Unit Tests on TFS 2013 Team Build worked around the problem by installing VS 2013 on the build server, but that means that the build server would use the 2013 testing framework rather than the version used by the developer.
Another option is to use an older build process template that uses MSTest, which supports the "ToolPath" parameter, but MSTest appears to be deprecated (MSTest V2). BTW, I tried using the MSTest V2 NuGet packages, but that didn't have any effect on the framework used by TFS, which made sense once I thought about it.
I assume that there should be some way to tie in a third-party testing framework, but the examples I've found use the older build process template.
Has anyone else found a solution for this?
If you need your test agent or test controller to work with TFS 2013,
use Agents for Microsoft Visual Studio 2013 Update 5 and
configure the test controller.
Source Link: Install and configure test agents
This is the official recommended practices, we don't suggest you to use some third-party testing framework for handling your situation (not sure if there were).
Besides just as MrHinsh commented, we encourage you to move to new web-based build system which is more excellent. For the detail benefit of VNext builds, you could refer to this article Why You Should Switch to Build VNext

Unit testing for modern PCL, compatible with .NET Core

I use Class Library (Portable) project template in Visual Studio to produce modern PCL, compatible with .NET Core. Unfortunately, I unable to run unit tests for PCL with neither NUnit nor XUnit:
First of all, I can't create Class Library (Package) or Console Application (Package) for unit testing project. VS 2015 currently does not allow to reference modern PCL from these types of project: https://github.com/aspnet/Home/issues/1099
Therefore, I should use Class Library (Portable) project for unit testing project.
That's why I can not follow articles http://www.alteridem.net/2015/11/04/testing-net-core-using-nunit-3/ (for NUnit) and https://xunit.github.io/docs/getting-started-dnx.html (for xUnit). Both articles use Class Library (Package) and Console Application (Package) projects.
I can't install 'xunit' package to Class Library (Portable) project. It fails with that error: https://github.com/xunit/xunit/issues/587
I can successfully build Class Library (Portable) project with NUnit 3. But currently there are no test runner that can run NUnit 3 tests for .NET Core. Not sure if latest version of Resharper supports that - in any case Resharper is not an option for me.
It looks that I need to wait either for bug fixes in modern PCL support or for .NET Core-compatible NUnit 3 test runner. Could you recommend any workaround?
The NUnit team and I have released full .NET Core support, including running tests within Visual Studio's Test Explorer. See NUnit 3 Tests for .NET Core RC2 and ASP.NET Core RC2 for more info.

Unit Testing .NET 3.5 projects using MStest in VS2010

There's a bug/feature in Visual Studio 2010 where you can't create a unit test project with the 2.0 CLR.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=wsignin1.0
This causes all sorts of problems when the project being tested is targetting the 2.0 CLR (ASP.NET MVC 2 on top of .Net 3.5 SP1 in this case) - crashes on debug, tests failing unexpectedly, in one case the test project doesn't even build because of the dependency on System.Web 2.0.0.0 which isn't available in projects targetting 4.0.
It's not possible to change the test project to target the 3.5 framework.
Does anyone know of a workaround?
Workarounds I'm aware of, but want to avoid, include:-
1) Upgrading the whole solution to target .NET 4
I want to host on Azure and it isn't clear at this point if/when support for .NET 4.0 will be added. See .NET 4.0 on Windows Azure?
2) Rolling the whole project back to Visual Studio 2008
This is a last resort as there are a number of features in 2010 that I really want to use
3) Building the unit tests in 2008 and managing the references manually
This will work, but it'll be a tremendous pain.
Any ideas?
It looks like Visual Studio 2010 Service Pack 1 will resolve this once it is released (see the heading 'Better platform support | Unit Testing on .NET 3.5')
You can get the Beta version with a Go-Live licence now...
You haven't suggested changing to a different test framework. Personally, I use NUnit and have for years. It's far more sophisticated that the stuff in 2008. I haven't had time to see what's changed in 2010 but I can't see MS catching up that quickly.

VSTS Unit test - build system

I have developed a build system on MSBuild (NET 3.0) and cc.net to perform continuous integration builds of a Visual Studio 2008 application, however a developer on the team recently added a VSTS unit test project to the mix. Is there any SDK or add-in provided by microsoft to allow this to be compiled on a non-team system build environment?
You can run the tests from the command-line, but it requires that the Test Edition of Visual Studio be installed on your build server:
http://devlicio.us/blogs/derik_whittaker/archive/2008/09/25/clean-build-server-with-mstest-fail.aspx
http://aspadvice.com/blogs/ssmith/archive/2008/03/18/Continuous-Integration-Setup-with-MSTest.aspx
This person is doing MSTest with CC.NET, so it might be helpful:
http://testearly.findtechblogs.com/default.asp?item=630602
In general, this is a main reason why many people choose something like NUnit, xUnit.NET or MbUnit over MSTest.
If you use MSTEST You will have to put that edition on the build server. To cut a long story short youd be better off changing the testing framework the developer is using from MStest to Nunit.
Its a much lighter solution.