Making Your List and Checking It Twice

Slides:



Advertisements
Similar presentations
Unit Testing in SQL Richard Fennell Engineering Director SqlBits 6 th October 2007.
Advertisements

Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
Module 17 Tracing Access to SQL Server 2008 R2. Module Overview Capturing Activity using SQL Server Profiler Improving Performance with the Database Engine.
#sqlsatPordenone #sqlsat367 February 28, 2015 Testing your databases Alessandro
Continuous Integration for Databases Learn how to automate your build and test Steve Jones Red Gate Software Part II of the Continuous Delivery for Databases.
SQL Server 2008 Basmah AlQadheeb-213 MIS What is a Database ? A database is a collection of Data that is organized so that it can easily be accessed,
DB Audit Expert v1.1 for Oracle Copyright © SoftTree Technologies, Inc. This presentation is for DB Audit Expert for Oracle version 1.1 which.
Introduction to SQL 2005 Security Nick Ward SQL Server Specialist Nick Ward SQL Server Specialist
1MIS 2008 / Merging Two Data Collections: Lessons Learned from the CCD-EDEN Merger EDEN Best-Practice Sharing Oregon File Preparation Practices.
How a little code can help with support.. Chris Barba – Developer at Cimarex Energy Blog:
UNIT TESTING FOR SQL Prepared for SUGSA CodeLabs Alain King Paul Johnson.
ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007.
Performance Dash A free tool from Microsoft that provides some quick real time information about the status of your SQL Servers.
Database Change Management One solution to an often complex problem Kevin Hurwitz Headspring Systems
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
DATABASE TOOLS CS 260 Database Systems. Overview  Database accounts  Oracle SQL Developer  MySQL Workbench.
SQL Server 2000 Sys Admin Jeremiah Curtis Engineering Services
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Database projects in visual studio 2010 Anthony Brown
Database Projects in Visual Studio Improving Reliability & Productivity.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Confidencial - TRACASA Automatize test [e- Reporting]
Visual Studio 2012: A Complete IDE (Debugging & Source Control) Kevin Howell.
SSMS SQL Server Management System. SQL Server Microsoft SQL Server is a Relational Database Management System (RDBMS) Relational Database Management System.
Backup Tables in SQL Server. Backup table method Cape_Codd database is used in this example 1.Righ click the database that contains the table you want.
Continuous Integration for Databases Steve Jones SQLServerCentral Red Gate Software.
Unit Testing with tSQLt
Blog: R YOU READY FOR.
Improve query performance with the new SQL Server 2016 query store!! Michelle Gutzait Principal Consultant at
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
MANAGEMENT DATA WAREHOUSE AND DATA COLLECTOR Ian Lanham.
Continuous Integration for Databases Steve Jones SQLServerCentral Red Gate Software.
DBMS Programs MS SQL Server & MySQL
SQL Compare & SQL Refactor
Visual Studio Database Tools (aka SQL Server Data Tools)
Query Optimization Techniques
Introduction to unit and integration testing with tSQLt
Introduction to Microsoft SQL Server 2016
Outsourcing Database Administration
Glasgow, SQL Server Meetup
Data Virtualization Demoette… Data Lineage Reporting
6/16/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Data Virtualization Demoette… JDBC Clients
Database Unit Testing Fundamentals
DBA and IT Professional for ~9 years. Currently I am a Data Architect
Dynamic SQL: Writing Efficient Queries on the Fly
Using FileTables Sam Nasr, MCSA, MCT, MVP NIS Technologies
Automated and Repeatable Test Cases for SQL Server Development
Using FileTables Sam Nasr, MCAD, MCTS, MVP NIS Technologies
Mapping Shema and Recursively Managing Data
EZ Positioning with SINAMICS S120 Agenda
Testing Database Code with tSQLt
DevOps Database Administration
Continuous Integration For Databases
DevOps Database Administration
Prove to your boss your database is sound - Unit Testing with tSQLt
Intro to Unit Testing with tSQLt
Database Unit Testing Fundamentals
Visual Studio Database Tools (aka SQL Server Data Tools)
Dynamic SQL: Writing Efficient Queries on the Fly
DBA for ~4+years, IT Professional for 7.5 years.
Outsourcing Database Administration
SSDT and Database Project Basics
Introduction to VSTS Database Professional
Dynamic Sql Not so scary?
SQL Server Fundamentals for Beginners
Query Optimization Techniques
Ch 1 .Installing and configuring SQL Server 2005
Samir Behara, Senior Developer, EBSCO
Presentation transcript:

Making Your List and Checking It Twice Unit Testing with tSQLt Elizabeth Noble elizabeth.a.noble@outlook.com @SQLZelda

Agenda What is unit testing How to setup tSQLt Create and run unit tests

Purpose of Unit Testing Test a single part of functionality Confirmation that functionality works New development Existing bugs

Advantages of Unit Testing Over time develop a collection of unit tests Confirm existing functionality did not break Find defects earlier in the development cycle

Downsides of Unit Testing Time consuming to create unit tests Can be difficult to design unit tests Does not test interactions with other parts of the system

How to Setup tSQLt Download tSQLt http://tsqlt.org/downloads/ 

How to Setup tSQLt CLR must be enabled Set database to TRUSTWORTHY EXEC sp_configure 'clr enabled', 1; RECONFIGURE; Set database to TRUSTWORTHY ALTER DATABASE < database name > SET TRUSTWORTHY ON;

How to Setup tSQLt Run tSQLt scripts Run the tSQLt.Class.sql http://tsqlt.org/user-guide/quick-start/#InstallToDevDb

How to Setup tSQLt Setup shortcut to run tSQLt Open SQL Server Management Studio Tools -> Options -> Keyboard -> Keyboard Shortcuts Shortcut: CTRL + 0 Stored procedure: EXECUTE <database name>.tSQLt.RunAll;

Create and Run Unit Tests Determine what should be tested Design unit test to fail Write SQL to get unit test to succeed Repeat as needed

Set up tSQL NewTestClass – creates a schema to group unit tests test – begin stored procedure names NewTestClass – creates schema that lumps all units tests and related objects FakeTable – makes a copy of the table; if it is not used, IDENTITY column may be incremented SpyProcedure –not used to test current stored procedure, used to run a stored procedure in a stored procedure test stored procedure - Stored procedure must begin with "test" at the beginning to be run as a unit test

Creating tSQL unit tests FakeTable – allows tests to be run on a copy of the actual table SpyProcedure – runs a copy of a stored procedure AssertEqualsTable – compares table results of actual versus expected NewTestClass – creates schema that lumps all units tests and related objects FakeTable – makes a copy of the table; if it is not used, IDENTITY column may be incremented SpyProcedure –not used to test current stored procedure, used to run a stored procedure in a stored procedure test stored procedure - Stored procedure must begin with "test" at the beginning to be run as a unit test

Demo

Conclusion Use unit tests to confirm functionality Install tSQLt in a development environment Think small when developing unit tests Design units tests to fail to avoid false positives

Additional Topics tSQLt - http://tsqlt.org/user-guide/quick-start/#InstallToDevDb Other options SQL Test - http://www.red-gate.com/products/sql-development/sql-test/ MSDN - https://msdn.microsoft.com/en-us/library/aa833283(v=vs.100).aspx SQL Cop - http://sqlcop.lessthandot.com/ Related topics Source control

Questions