Douglas Gaskell
Douglas Gaskell

Reputation: 10080

Travis Unit tests failing: Reference 'Microsoft.VisualStudio.QualityTools.UnitTestFramework' not resolved

I'm trying to set up Travis CI tests for my repository here: https://github.com/douglasg14b/CSVSerializer

The tests pass locally, but with Travis CI I get the following warning and error:

/usr/lib/mono/xbuild/14.0/bin/Microsoft.Common.targets: warning : Reference 'Microsoft.VisualStudio.QualityTools.UnitTestFramework' not resolved

CSVSerializerTests.cs(1,17): error CS0234: The type or namespace name VisualStudio' does not exist in the namespaceMicrosoft'. Are you missing an assembly reference?

How can I go about resolving this?

Upvotes: 1

Views: 567

Answers (1)

StumpDK
StumpDK

Reputation: 441

According to this answer, it seems like the referenced package Microsoft.VisualStudio.QualityTools.UnitTestFramework only is available with Visual Studio installed. And that isn't possible when running tests on Travis' build systems, which are running Linux.

A simple solution to this problem is to use Nunit, a test framework that also works with Mono, the Linux implementation of .NET. To use it, simply implement a Shim class that covers the functionality of your tests, remove the original reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework from the project's references, and you are good to go.

Here's what to do:

  1. Install the following packages in Visual Studio Using NuGET package manager:

    • Nunit Test Adapter

    • Nunit

    • nunit.framework

  2. To get rid of the dependency to the Microsoft.VisualStudio.QualityTools.UnitTestFramework add this shim class to your test project.

  3. Removed the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework in your test project.

  4. Run the tests

  5. Commit your project and see it run in Travis CI

Upvotes: 1

Related Questions