0

I am looking at the documentation at MSDN for the "Microsoft Unit Test Framework for Managed Code" and I don't see how to run the tests from command line with VS 2015.

Is this documented by Microsoft somewhere? I have found a question that is correct for VS 2010, but I thought that in VS 2015 this stuff was rebuilt. I am currently trying to get this working for C# with a .NET 4 class library and .NET 4 framework application's code. Currently I have unit test assemblies that can only be manually run within the IDE.

I am trying to figure out if someone wants to build and run unit tests and integration tests on a build server, and those tests are built with the latest Visual Studio 2015 frameworks, if one still has to modify one's project msbuild files manually, install the entire Visual Studio tool on the CI-server/build-server in order to run the tests, and also if one has to manually edit one's MS BUILD project files to ADD command line test targets to it, which seems feeble to me. I was hoping Microsoft had improved this but it looks like the situation is as dire and lame as it was in 2010. As of 2010 era, only TFS toolking was provided, and anyone who doesn't use TFS was left out in the cold. Has this been improved in Visual Studio 2015?

Update: It looks like I can run MSTEST.exe /testcontainer:<dllname> directly from the command line in Visual Studio 2015 developer command prompt. This works for my unit tests, but not for integration tests (which have a real data access layer). This seems easier than trying to get this working INSIDE msbuild. It looks like just like when MSTEST runs inside Visual Studio, each run produces an output folder, containing a binary copy of the .net assembly under test, and all its referenced assemblies. Maybe it's time to switch to xUnit, as MSTEST looks grotesque to me.

Community
  • 1
  • 1
Warren P
  • 65,725
  • 40
  • 181
  • 316
  • I just want to make sure I'm understanding this properly: You're trying to set up a build server to run builds and automated tests without installing the TFS build server clients? – Taegost Mar 01 '16 at 18:35
  • I want to use Jenkins, and MSBUILD, and NO TFS Server. If I have to install Visual Studio on the build server, so be it. Right now, I'm on a developer workstation, and I simply want to write a "buildandtest.cmd" batch file which will launch an msbuild target, or else, directly launch mstest.exe, or something. – Warren P Mar 01 '16 at 18:43
  • Well, if you're using Jenkins, have you tried looking up information regarding integrating builds and testing with Jenkins? This article looks promising: http://dotdotnet.blogspot.com/2011/11/building-net-application-with-jenkins.html – Taegost Mar 01 '16 at 18:50
  • That definitely looks relevant. I suppose part of the problem here is that MSTEST is just bizarre when you're used to other unit test frameworks. I never would have imagined that MSTEST is a piece of VS and not a piece of MSBUILD itself. I just assumed it would be more like other build systems. It seems MSBUILD and MSTEST are like two estranged cousins. – Warren P Mar 01 '16 at 18:55
  • I've always used them in conjunction with TFS so I never had to worry about that... But your description sounds about right! – Taegost Mar 01 '16 at 19:01
  • 1
    I use the Jenkins MSTest and MSTestRunner plugins to run the unit tests on a project after a build. Just setup the plugin to location of the MSTest.exe and in the project pass in the DLL you want to run the tests on. All results are in the output. – JAZ Mar 01 '16 at 19:23
  • I also want to run from a command line. I guess a batch file will do. – Warren P Mar 01 '16 at 21:27

1 Answers1

1

MSTest are two things, a framework, which is still valid, and a runner, which is - though still valid - not much used, since it has been replaced with the VSTest runner. You can run any framework with VSTest, MSTest, NUnit or XUnit. To run from commandline, look at this https://msdn.microsoft.com/en-us/library/jj155796.aspx

Terje Sandstrøm
  • 1,979
  • 15
  • 14