How to: Open a Database Unit Test to Edit
This topic applies to:
Visual Studio Ultimate |
Visual Studio Premium |
Visual Studio 2010 Professional |
Visual Studio Express |
---|---|---|---|
After you create a database unit test, you use the Database Unit Test Designer to add Transact-SQL statements and test conditions. The tests created by using the designer generate Visual C# or Visual Basic code. This code is what executes when your test runs.
If the test that you create tests the database object to your satisfaction, you can run it as it is. If you want to add more functionality to this database unit test, you can edit its code. This code resides in a .cs or .vb file in your test project. For more information, see Database Unit Test Files. You can also customize your tests by creating new test conditions. For more information, see How to: Create Test Conditions for the Database Unit Test Designer.
Note
If you delete a test method by editing the .cs or .vb file, the test method still appears in the Database Unit Test Designer. This situation occurs because the InitializeComponent method of the test class still contains member variables for that test. Although the test appears in the designer, you cannot run the test because its code is no longer present. To regenerate the test method for this test, edit the Transact-SQL in the editor, and then either save the .cs or .vb test file or rebuild the test project.
To open the source code file of a database unit test from Solution Explorer
In Solution Explorer, right-click the source-code file that contains the database unit test, and then click View Code.
In the main editing window of Visual Studio, the test method of the database unit test appears when the file opens.
To open the source code file of a database unit test from the Test View window
Run a database unit test.
In the Test View window, right-click the test, and then click Open Test.
In the main editing window of Visual Studio, the test method of the database unit test appears when the file opens.