Is there anything I can do in NUnit that I can't do in MSTest?

后端 未结 12 1493
南笙
南笙 2020-12-23 20:10

This question has been asked in various forms in a number of different forums, but, IMHO, I haven\'t been able to find a place where it\'s really answered clearly, so I\'m g

12条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 21:01

    Roy, Bunch of your information is out of date especially as it relates to 2010;

    Nunit contains a [TestCase] attribute that allows implementing parametrized tests. this does not exist in MSTest

    This can be implemented using unit test extensibility in 2010.

    MSTest's ExpectedException attribute has a bug where the expected message is never really asserted even if it's wrong - the test will pass.

    Correct thats still there

    NUnit has an Assert.Throws API to allow testing an exception on a specific line of code instead of the whole method (you can easily implement this one yourself though)

    Jim implented a version of Assert.Throws for MSTest at the same time as he did the original implementation for NUnit, NUnit has included in subsequent releases, MSTest has not, its still possible to use though.

    NUnit contains a fluent version of Assert API (as already mentioned - Assert.That..)

    There are several of these implemented by 3rd parties for MSTest

    NUnit is much faster

    See Jamie's comment he has managed to get MSTest running faster :-)

    NUnit can run tests in 32 and 64 bit (MSTest only runs them in 32 bit IIRC)

    Not in 2010, 64 bit support is built in.

    NUnit allows abstract classes to be test fixtures (so you can inherit test fixtures). MsTest does not.

    This works but not across assemblies which does limit its usefulness.

    NUnit allows non public classes to be test fixtures (as of the latest version)

    Still there

    NUnit was created SOLELY for the idea of unit testing. MSTest was created for Testing - and also a bit of unit testing.

    Correct, there is a lot of misconception that MSTest is the same as Nunit but MSTest is a generalized framework.

    NUnit contains PNunit (running parallel tests with NUnit). MSTest only adds this ability in vs 2010

    Correct there is an XML config setting that allows control of degree of parallelism.

提交回复
热议问题