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");
}
Related Contents:
- How do I use Assert to verify that an exception has been thrown with MSTest?
- How can we run a test method with multiple parameters in MSTest?
- MSTest: No tests are run because no tests are loaded or the selected tests are disabled
- Unit testing private methods in C#
- Your project does not reference “.NETFramework,Version=v4.6.2” framework. Add a reference to “.NETFramework,Version=v4.6.2” in the “TargetFrameworks”
- How to compare Lists in Unit Testing
- Unit Testing: DateTime.Now
- Why does TestInitialize get fired for every test in my Visual Studio unit tests?
- Use NUnit Assert.Throws method or ExpectedException attribute?
- How can I write output from a unit test?
- How can I get “Copy to Output Directory” to work with Unit Tests?
- How can I reset an EF7 InMemory provider between unit tests?
- How do I check “no exception occurred” in my MSTest unit test?
- Problems with DeploymentItem attribute
- Why does this assert throw a format exception when comparing structures?
- Why does Assert.AreEqual(T obj1, Tobj2) fail with identical byte arrays
- TestInitialize vs ClassInitialize
- MSTest Equivalent for NUnit’s Parameterized Tests?
- Can’t read app.config in C# .NET Core unit test project with ConfigurationManager
- What’s the difference between Assert.AreNotEqual and Assert.AreNotSame?
- Stepping through and debugging code in Unit tests
- DataTestMethod and DataRow attributes in MSTEST
- Microsoft unit testing. Is it possible to skip test from test method body?
- Why does Assert.IsInstanceOfType(0.GetType(), typeof(int)) fail?
- How to set test category for all tests in the class
- Classes marked with TestInitialize and TestCleanup not executing
- C# “internal” access modifier when doing unit testing
- Using Moq to mock an asynchronous method for a unit test
- Unit testing void methods?
- Unable to find testhost.dll. Please publish your test project and retry
- Setting HttpContext.Current.Session in a unit test
- Test parameterization in xUnit.net similar to NUnit
- how to unit test asp.net core application with constructor dependency injection
- Moq verify with object parameter
- Making a private method public to unit test it…good idea?
- How to get Directory while running unit test
- Using IoC for Unit Testing
- How to mock ModelState.IsValid using the Moq framework?
- Best Practices of Test Driven Development Using C# and RhinoMocks [closed]
- Using Moq to verify calls are made in the correct order
- Is it possible to mock out a .NET HttpWebResponse?
- NUnit 3.0 and Assert.Throws
- Unit test for thread safe-ness?
- Mock IHttpContextAccessor in Unit Tests
- Unit Test C# [TestInitialize]
- Rhino Mocks AssertWasCalled (multiple times) on property getter using AAA
- Unit test the Automapper profiles
- How to Unit Test Startup.cs in .NET Core
- Mock IMemoryCache with Moq throwing exception
- Mocking classes that implement IQueryable with Moq