Some Key Features of the SqlServer Data Tools are
- Model Based declarative Development and validation
- Offline development using lighter weight Localdb which comes with SSDT and doesn't require a separate instance of database to be installed
- Uses Power Buffer for Declarative Development ,Power buffers hold a model of the database by which you can make changes to the table structures and alter the programming constructs without affecting the actual database until we are ready to commit the changes
- Refactoring support for database objects which enables to rename ,move objects and preview all the effected dependent changes
- Snapshots allow to hold the point in time copy of the database project
- SchemaCompare gives the ability to compare the local database project with the target database for schema changes
- Easy to create sandbox dev,test environments by cloning the production database for schema and data
- Server Explorer in SSDT resembles object explorer of SSMS
- Drift detection in SSDT enables to keep update with any new changes to the database after we create the database project in visual studio
- SSDT can be used for database unit testing when you have visual studio2010/2012 professinal or higher edition
- Can be used to target sql server 2005/2008 and SqlAzure
Unit Testing using SqlServer Data Tools SSDT Step by Step.
For this demo i'm creating a schema with one table and a stored procedure ,the table name is called Product and the stored procedure NewProducts inserts records into the table as shown below
In the next step i will create a new database project in SSDT by slecting the file menu and project as shown below
In the next step i have selected the SqlServer Database Project template as shown below
Than i have imported the schema by going to Project Menu than to Import and selected the SQLScipt
On the import Sql wizard click next
In the next step you need to select the location of the sqlfile
Click next and finish .After importing the sql script go to Projects and check the newly created tables and stored procedure in the database of the projects node.
Press F5 which deploys the database and creates a Localdb under the databases section of localdb\projects as shown below
In the next step i will create a unit test for the stored procedure NewProduct
Right click the StoredProcedure and select create unitests as shown below
I have selected the necessary stored procedures for unit testing in this case i have only one called NewProducts as shown below a
I need to configure the the test configuration wizard which follows after the previous step or you can right click the testproject created and select the SQLServer test configuration
In the next step under the sqlserver test configuration wizard select the check box under deployment under the database project section select the project which we created earlier and under deployment configuration select the debug which is shown on the earlier wizard
In the next step i have amended the test logic which was created by earlier step by giving the variable for prodcut name as testproduct as shown below
Than under test condition delete the inconclusive condition
After deleting the test condition than ,select row count from the dropdown list
The new test condition as shown below
Open the properties for the test condition and change the row count property to 1 as shown below
Than go to the test menu windows and select test explorer as shown below
As you can see the test runs successfully and that concludes the demo.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.