11

I'm trying to setup a post-build event in .NET 3.5 that will run a suite of unit tests w/ MS test. I found this post that shows how to call a bat file using MbUnit but I'm wanting to see if anyone has done this type of thing w/ MS Test?

If so, I would be interested in a sample of what the bat file would look like

Toran Billups
  • 27,111
  • 40
  • 155
  • 268

3 Answers3

10

We were using NUnit in the same style and decided to move to MSTest. When doing so, we just added the following to our Post-Build event of the applicable MSTest project:

CD $(TargetDir)
"$(DevEnvDir)MSTEST.exe" /testcontainer:$(TargetFileName)

The full set of MSTest command line options can be found at the applicable MSDN site.

David Beckman
  • 605
  • 8
  • 17
3

Personally I would not recomment running unit tests as a part of the compilation process. Instead, consider something like ReSharper (+ appropriate Unit Test Runner or how do they call these nowadays) or some other GUI runner.

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
2

Instead of a doing it in a post build event, that will happen every time you compile, I would look at setting up a Continuous Integration Server like CruiseControl.Net. It'll provide you a tight feedback cycle, but not block your work with running tests every time you build your application.

If you are wanting to run the set of tests you are currently developing, Anton's suggestion of using ReSharper will work great. You can create a subset of tests to execute when you wish and it's smart enough to compile for you if it needs to. While you're there picking up the demo, if you don't already have a license, pick up Team City. It is another CI server that has some promise.

If you are wanting to use this method to control the build quality, you'll probably find that as the number of tests grow, you no longer want to wait for 1000 tests to run each time you press F5 to test a change.

Mark
  • 9,966
  • 7
  • 37
  • 39
  • Good suggestions - I am using VS2008 and can run my tests quickly (as you mentioned R#). We purchased TFS late last year ... but for some reason the team dedicated to getting this up is taking some time :( – Toran Billups Feb 03 '09 at 16:37
  • For now, you could setup CC.Net, or another CI server besides Team Build, to run on your local box, or a make-shift server (aka an unused desktop) stuck under someone's desk. We struggled with getting the "enterprise" team to setup the "enterprise" solution so we did it our self. – Mark Feb 03 '09 at 16:51
  • The downside of running it on the CI server instead of part of the compile is that devs won't be alerted of breakage. It's common for a dev to uknowingly push changes that cause the CI server to fail which causes alot of churn and shame :) – pmont Jul 02 '14 at 15:11