vs-unit-testing-framework

How to run a test method with multiple parameters in MSTest?

不打扰是莪最后的温柔 提交于 2019-11-26 15:48:28
NUnit has a feature called Values, like below: [Test] public void MyTest( [Values(1,2,3)] int x, [Values("A","B")] string s) { // ... } This means that the test method will run 6 times: MyTest(1, "A") MyTest(1, "B") MyTest(2, "A") MyTest(2, "B") MyTest(3, "A") MyTest(3, "B") We're using MSTest now, is there any equivalent for this so that I can run the same test with multiple parameters? [TestMethod] public void Mytest() { // ... } jeroenh It is unfortunately not supported in MSTest. Apparently there is an extensibility model and you can implement it yourself . Another option would be to use

How do I use Assert to verify that an exception has been thrown?

喜欢而已 提交于 2019-11-26 15:35:29
How do I use Assert (or other Test class?) to verify that an exception has been thrown? For "Visual Studio Team Test" it appears you apply the ExpectedException attribute to the test's method. Sample from the documentation here: A Unit Testing Walkthrough with Visual Studio Team Test [TestMethod] [ExpectedException(typeof(ArgumentException), "A userId of null was inappropriately allowed.")] public void NullUserIdInConstructor() { LogonInfo logonInfo = new LogonInfo(null, "P@ss0word"); } ojrac Usually your testing framework will have an answer for this. But if it's not flexible enough, you can

How to run a test method with multiple parameters in MSTest?

て烟熏妆下的殇ゞ 提交于 2019-11-26 05:59:45
问题 NUnit has a feature called Values, like below: [Test] public void MyTest( [Values(1,2,3)] int x, [Values(\"A\",\"B\")] string s) { // ... } This means that the test method will run 6 times: MyTest(1, \"A\") MyTest(1, \"B\") MyTest(2, \"A\") MyTest(2, \"B\") MyTest(3, \"A\") MyTest(3, \"B\") We\'re using MSTest now, is there any equivalent for this so that I can run the same test with multiple parameters? [TestMethod] public void Mytest() { // ... } 回答1: It is unfortunately not supported in