Search code examples
c#.netvisual-studio-2010mstest

What are Contexts in MSTests?


I keep wondering what are Contexts when it comes to Unit testing. There seem to be 3 options for doing tests in Visual Studio:

  1. All Tests in the Current Context
  2. All Tests in Solution
  3. All Impacted Tests

Point 2) is quite obvious to me, but I don't understand what Points 1) and 2) mean.

Thanks


Solution

    1. All Tests in the Current Context: The current context depends on where your cursor is. If it's in a method, that test method will be run. If it's in a class, but not in a method, all test methods in the class will be run
    2. All Tests in Solution: Runs all tests
    3. All Impacted Tests: Visual Studio figures out which test methods need to be run to test any changes you've made in your code. It runs only those tests that test the changed code. The main benefit of this feature is when you have a large number of test methods, you don't need to run the entire set of tests, which can take a while. You can read more about this here: Link