Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there "Dynamic Playlists" of unit tests in Visual Studio?

When working with unit tests in Visual Studio, it's possible to compile playlists that group the tests. This is useful, for instance, when developing a new feature for which we want to run only the related tests and not all the existing ones.

However, it seems to me the playlists can only be maintained "manually", by explicitly adding/removing unit tests.

It's better than nothing, but it would be great if I could some how "tag" my unit tests depending on some criterion (e.g. feature, test duration, etc.) and generate the playlists dynamically.

Is there any way to do something similar in Visual Studio with the default testing framework?

like image 487
elnigno Avatar asked May 07 '14 08:05

elnigno


People also ask

How do I create a test playlist in Visual Studio?

To create a playlist, choose one or more tests in Test Explorer. Right-click and choose Add to Playlist > New playlist. To open a playlist, choose the playlist icon in the Visual Studio toolbar and select a previously saved playlist file from the menu.

How do I automate unit testing in Visual Studio?

To generate unit tests, your types must be public. Open your solution in Visual Studio and then open the class file that has methods you want to test. Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.

Do unit tests run in parallel C#?

Unit tests run one at a time. There is no parallelism. See attached screenshot. We have directed your feedback to the appropriate engineering team for further evaluation.


1 Answers

You can run certain tests contextually in relation to the current cursor position by right clicking and then "Run Tests", or hitting CTRL+R then T.

  • If the cursor is within the body of a test, only that test will be run.
  • If the cursor is within the body of a test class, only the tests in that class will be run.
  • If the cursor is within a namespace, all tests in that namespace will be run.

See MSDN documentation on the subject.

Alternatively you can filter the test explorer in various ways. I often use the Project flag to exclude certain projects for instance.

like image 159
GazTheDestroyer Avatar answered Sep 20 '22 13:09

GazTheDestroyer