views:

31

answers:

3

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

+1  A: 

Tests in the Current Context : This option works if your cursor is inside a test method and if selected, would run test inside the boundaries of that particular method only.

All Tests in Solution : If your cursor is outside a method, selecting this option will run whole tests in you test class(es).

All Impacted Tests : Not sure about that as I switched to NUnit at very early days of Unit testing. My instance of Visual studio 2008 is not showing this option either so that I could check how this will behave. Would love to know any way.

hope it helps

Asad Butt
+1  A: 

I believe "Impacted Tests" is a new feature of VS2010. It will run the tests "impacted" by recent changes to your code. That is, it will look at what the tests seem to test, and if you have made changes to the code that they test, then that will be an impacted test.

John Saunders
+3  A: 
  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: http://blogs.msdn.com/b/phuene/archive/2009/12/07/test-impact-analysis-in-visual-studio-2010.aspx
Malcolm Haar