2

Travis CI now supports C# (in beta). After try 8 different methods, I can't find a solution to my problem.

I have an ASP MVC project, travis use mono and I know that I can't build in travis this kind of project

script:
    - xbuild project.sln

Ok no problem with this but I want to pass my tests, the best solution that I find is:

language: csharp
solution: OptionType.sln
install:
  - sudo apt-get install mono-devel mono-gmcs nunit-console
script:
  - nunit-console MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll 

but failed.. https://travis-ci.org/MSPSpain/Website/builds/43711017

936ProcessModel: Default    DomainUsage: Single

937Execution Runtime: mono-4.0

938Missing method .ctor in     assembly /home/travis/build/MSPSpain/Website/MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll, type     Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute

939Can't find custom attr constructor     image: /home/travis/build/MSPSpain/Website/MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll mtoken:     0x0a000011

940Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework,     Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

941

942The command "nunit-console MSPSpain.Tests/bin/Debug/MSPSpain.Tests.dll" exited with 254.

I searched a lot about this and I can't find the best solution to my problem.

CKGrafico
  • 145
  • 7

1 Answers1

3

Your tests are using MSTest and referencing the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly which is typically installed by Visual Studio.

The Microsoft.VisualStudio.QualityTools.UnitTestFramework will not be included with Mono.

Probably the simplest solution is to switch to using NUnit instead of MSTest if you want to run the tests on both Windows and Mono.

Whilst it is possible to get MSTest installed without Visual Studio on Windows I suspect this will not be possible on a non-Windows operating system.

Community
  • 1
  • 1
Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • Thanks! I will try with this method – CKGrafico Dec 11 '14 at 15:20
  • This solution helps me a lot but is not definitive https://travis-ci.org/MSPSpain/Website/builds/43731707 – CKGrafico Dec 11 '14 at 16:00
  • The project has references to Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly which is why it is still failing. It will be simpler to remove this reference, add a reference to NUnit.Framework and only use NUnit for testing. It is possible to support both but it that would be more work since you would need two different build configurations and have conditional references, one for NUnit and one for MSTest. – Matt Ward Dec 11 '14 at 16:53
  • Yep I'm sorry was my fault, your solution works perfect https://travis-ci.org/MSPSpain/Website/builds/43761773 – CKGrafico Dec 11 '14 at 21:00