0

Mstest 10.0.1.0 is not recognizing ExpectedException.

I used Msbuild to generate unit test dlls.

It seems that [ExpectedException] is not working:

[ExpectedException(typeof(ArgumentNullException))]
public void Test(){
    throw new ArgumentNullException("test");
}

failed when run by mstest.

The unit test project is referencing

Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.1.0

(^ I got this info by decompiling)

Question:

  1. Is this a bug of Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.1.0?

  2. How can I make the unit test project to use fixed version 10.0.0.0?

orange
  • 720
  • 3
  • 11
  • 27
  • 1
    Possible duplicate of [ExpectedExceptionAttribute is not working in MSTest](http://stackoverflow.com/questions/1169057/expectedexceptionattribute-is-not-working-in-mstest) – Kritner Nov 10 '16 at 17:22
  • If you like to use [fluentassertions](http://www.fluentassertions.com/), you can also use following approach. This comes without _ExpectedException_ attribute `[TestFixture] public class ExceptionTests { [Test] public void Test() { Action action = () => { throw new ArgumentNullException("test"); }; action.ShouldThrow(); } }` – Dominik Herold Nov 11 '16 at 09:06

0 Answers0