Reputation: 12601
I've read time and time again that TDD/test first is more difficult with MSTest than it is with other testing frameworks such as nUnit, MBUnit, etc... What are some suggested manual workarounds and/or 3rd party bits that you suggest when MSTest is the only option due to infrastructure policy? I'm mainly wondering about VS 2008 Team Suite, but I suppose tips for VS 2008 Pro on up would be suitable too since some MSTest functionality is now included with those versions as well.
Upvotes: 19
Views: 4277
Reputation: 7487
MSTest is certainly not as efficient or extensible as some of the open source frameworks, but it is workable. Since the question asks about making life easier with MSTest and not about alternatives, here are my MSTest tips.
Upvotes: 29
Reputation: 59001
If you have no choice but to use MSTest, learn the keyboard shortcuts. They'll make your life a little easier.
Test in Current Context: CTRL+R, T
All Tests in Solution: CTRL+R, A
Debug Tests in Current Context: CTRL+R, CTRL+T
Debug All Tests in Solution: CTRL+R, CTRL+A
Upvotes: 13
Reputation: 123
I've done TDD development using NUnit for a number of years and have been using MSTest for about 4 months now due to a role change.
I don't think that MSTest stops someone from doing TDD. You still have all the core things you need for TDD such as basic asserts and mocking frameworks (I use Rhino Mocks).
MSTest does integrate closely with Visual Studio, the best component of this integration is the Code Coverage Tool that is built in.
BUT There are a number of compelling reasons not to use MSTest. The two biggest turn offs in my opinion are:
This means that writing asserts takes more code in combination with a slow test runner means that the whole process is slower than NUnit. The open source options also have a lot more support in the community.
If you are using TFS for CI, then you will need to jump through a few hoops/hacks to get NUnit to publish test results. Running tests on TFS with MSTest in comparison is very easy and straight forward. If you don't touch TFS than I'd go NUnit all the way, it's just nicer.
Upvotes: 1
Reputation: 31
as mentioned oyu need to install the full IDE in order to use MSTest on another machine, which is a bit crap. I suppose this is because they want to make sure that unit tests only works on the higher end visual studios and you sholdné be able to run them in any other way.
ALso, MSTest is quite slow, this is because inbetween each test it rebuilds the entire context for each test, this makes o0ne sure that a former test - failed or otherwise doen't infuence the current test, but slows things down. you can however use the /noisolation flag, which will run all tests within the MSTest process - which is quicker. To speed up in IDE: In the VS ide you can go to Tools-Options then select Test Tools. Select sub-item called Test execution and in dialouge to the right make sure the check box called 'Keep test execution engine running between test runs' is checked.
Upvotes: 2
Reputation: 6510
I'm curious here. What I don't understand is that people start comparing all Open Source tools available with MSTest and start bashing it. Commenting on how unwieldy it is, how unintiuitve etc. IMHO, it's because it's fundamentally different from xUnit frameworks. It's optimized for parallel execution.
Even the qurik of having static ClassInitialze and Cleanup and having unique TestContext for each of the tests all because of the nextgen - at least for Windows business programmers in MS languages - parallel progarmming concepts.
I had the misfortune of working in a project with tens of thousands of unit tests. They used to take virtually most of the build time! With MSTest, we cut that down to very managable timelines.
Upvotes: 6
Reputation: 1644
It just too hard to use and there are many better options.
Upvotes: 2
Reputation: 14282
My colleague Mike Hadlow has pretty good summary of why we utterly loath MSTest here.
He's managed to remove it from his project, but I'm currently working on a larger project with more politics involved so we're still using it.
The upshot of it is that whoever implemented MSTest doesn't understand TDD. I'm sorry to sound like an M$ basher - I'm really not. But I'm annoyed that I'm having to put up with a very poor tool.
Upvotes: 3
Reputation: 136603
To answer a non-pointed question, my answer would be "probably NUnit just stays out of your face."
Disclaimer: I've no actual experience with MS version of xUnit, however I hear problems like 'You need to install the gigantic idea just to run your tests on a separate machine' - which is a complete No-No. Other than that MS has this way of contorting the right path for a newbie via some kind of IDE bell/whistle that runs counter to the whole idea. Like generating tests from classes was one I remember from a year or so back.. that defeats the whole point of test-driving - your design is supposed to emerge from tiny steps of RGR: writing a test-make it pass-refactor. If you use that tool - it robs you of the entire experience.
I'll stop with my sermon.. now :)
Upvotes: 1
Reputation: 40788
There are lots of config files with mstest, making it less condusive.
Another reason I chose mbunit, is the "rollback" feature of mbunit. This allows you to rollback all database things done in this test, so you can actually do full circuit tests and not worry about the pond being tainted after the test.
Also lack of RowTest facilities in mstest.
I suggest just running mbunit as a dependency inside the build process, its easy enough to just float it with your bin, and reference, no installation required.
Upvotes: 2
Reputation: 26344
I have not seen any serious issues with MSTest. What, specifically, are you talking about? We are, in fact, moving away from NUnit to MSTest. I do not know our reasons for this, though.
Upvotes: 2