SlideShare ist ein Scribd-Unternehmen logo
1 von 32
#sqlsatParma 
Testing your databases 
Alessandro Alpi 
@suxstellino 
www.alessandroalpi.net 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Sponsors 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Organizers 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
About me 
 SQL Server MVP since 2008 
 Microsoft Certified 
 blogs: 
 [ITA] http://blogs.dotnethell.it/suxstellino 
 [ENG] http://suxstellino.wordpress.com/ 
 More details on: 
 http://www.alessandroalpi.net 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Agenda 
 ALM/DLM concepts 
 Unit Testing concepts 
 Why Unit Testing on databases 
 Unit Testing frameworks 
 Unit Testing solutions 
 Conclusions 
 Q&A 
November 22 #sqlsat355 nd, 2014
ALM is the product lifecycle management 
(governance, development, and maintenance) of 
application software. It encompasses requirements 
management, software architecture, computer 
programming, software testing, software 
maintenance, change management, project 
management, and release management. 
(source: Wikipedia) 
#sqlsatParma 
ALM definition 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Why ALM? 
 Breaking the team barriers (integration) 
 Release high quality software 
 Release software in quickly way 
 Customer satisfaction 
 Improved work organization 
 Monitoring and tracking the activities 
 Improved code (clear and easy to read) 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
How to reach the best Quality? 
 Continuous Integration! 
 DEVELOP 
 SEND 
 BUILD 
 TEST 
November 22 #sqlsat355 nd, 2014
DLM – Database lifecycle management 
DLM is a comprehensive approach to 
managing the database schema, data, and 
metadata for a database application. DLM 
begins with discussion of project design and 
intent, continues with database develop, test, 
build, deploy, maintain, monitor, and backup 
activities, and ends with data archive. 
(source: TechNet) 
#sqlsatParma 
November 22 #sqlsat355 nd, 2014
In computer programming, unit testing is a 
software testing method by which individual 
units of source code, sets of one or more 
computer program modules together with 
associated control data, usage procedures, 
and operating procedures are tested to 
determine if they are fit for use. The primary 
purpose of this approach is to find out bugs 
and prevent regressions. 
(source: Wikipedia) 
#sqlsatParma 
Unit testing 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Unit testing – Why? 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Unit testing – Why? 
 Mission-critical business functionality 
 Evolutionary development 
 Usage of mock/fake objects 
 We’re missing bugs 
 We’re missing potential regressions 
November 22 #sqlsat355 nd, 2014
«Fix bugs as soon as you find them» 
#sqlsatParma 
Then.. 
 Unfixed bugs camouflage other bugs 
 Unfixed bugs suggest quality isn’t important 
 Discussing unfixed bugs is a waste of time 
 Unfixed bugs lead to duplicate effort 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Lesson learned.. 
 Unfixed bugs lead to unreliable metrics 
 Unfixed bugs distract the entire team 
 Unfixed bugs hinder short-notice releases 
 Unfixed bugs lead to inaccurate estimates 
 Fixing familiar code is easier 
 Fixing a bug today costs less than tomorrow 
November 22 #sqlsat355 nd, 2014
 Executing the code on a copy of production data 
 Manual testing 
 Some test cases forgotten as the code changes. 
 Some test is made on structures with “test-unrelated” 
constraints which could break the test 
#sqlsatParma 
Unit testing – What we usually do? 
 T-SQL debug for checking variable values 
 PRINT, PRINT, SELECT… 
 Not repeatable and human errors (subjectivity) 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Unit testing – What do I test? 
 Calculations in procedures and functions 
 Constraints (schema) 
 Edge cases of data DML 
 Expected behavior of data DML 
 Error Handling 
 Security 
 Standards 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Unit testing – What can we use? 
 Frameworks 
 tSQLt 
 tSQLUnit 
 SQLCop 
 SS-Unit 
 Tools 
 SQLTest by Red-Gate (tSQLt + SQLCop) 
 Unit test project with Visual Studio 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Unit testing – tSQLt 
 Free framework (open source) 
 T-SQL 
 Requires SQLCLR to be enabled 
 Includes common assertions 
 Self-contained tests 
 Isolated transactions 
 Versatile 
 Similar to xUnit 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Unit testing – tSQLt structures 
 Built-in 
 tsqlt schema 
 Classes 
 Group of stored procedures (tests) 
 Model 
 Assemble (create fakes) 
 Act (apply logics) 
 Assert (verify results) 
 Conventions 
 Naming: test* 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
DEMO 1 
tSQLt and Red-Gate SQL Test 
+ 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Unit testing – Visual Studio 
 Visual Studio Data Tools 
 Unit test projects (created by template) 
 .Net + T-SQL 
 Supported also in VS 2013 
 Integrated Test UI (Test Explorer) 
 UI for test conditions 
 Pre/Post test scripts 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
DEMO 2 
Visual Studio database unit testing projects 
+ 
November 22 #sqlsat355 nd, 2014
tSQLUnit 
#sqlsatParma 
Unit testing – tSQLUnit 
 Free framework (open source) 
 T-SQL and SSMS 
 Self-contained tests 
 Isolated transactions 
 Versatile 
 Setup and reset 
 Similar to xUnit 
November 22 #sqlsat355 nd, 2014
tSQLUnit 
#sqlsatParma 
Unit testing – tSQLUnit structures 
 TestSuites 
 Is the name after ut_ prefix 
 Groups of procedures 
 User defined test (prefix ut_) 
 ut_TestSuiteName_WhatToDo 
 Built-in 
 tsu_ procedures 
 Fixtures 
 _setup procedures 
 ut_TestSuiteName_setup 
 _teardown procedures 
 ut_TestSuiteName_teardown 
 They execute for each test in the suite 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
DEMO 3 
tSQLUnit in SQL Server Management Studio 
+ tSQLUnit 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Features comparison – SQL Test 
 Pros 
 SSMS integration 
 Class execution 
 Messages and icons (UI) 
 T-SQL oriented 
 Self-contained 
 Supports tSQLt and SQLCop 
 Cons 
 Ui to be improved 
 Installs a set of objects 
 Needs SQLCLR 
 Needs TRUSTWORTHY ON 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Features comparison – Visual Studio 
 Pros 
 Visual Studio  
 Future support of project templates 
 Improved UI and designers 
 Does not need to add objects to database 
 Cons 
 Test project is not so comfortable 
 Test framework is not written in T-SQL 
 Out of SSMS (is this really a Con? ) 
 Different approaches on past VS versions 
November 22 #sqlsat355 nd, 2014
tSQLUnit 
#sqlsatParma 
Features comparison – tSQLUnit 
 Pros 
 T-SQL oriented 
 Based on well known xUnit framework 
 Does not need SQLCLR 
 Open source 
 Cons 
 No UI 
 Installs a set of objects on the database 
 Poor T-SQL based documentation 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Conclusions 
 There is no excuse for NOT testing like 
any other piece of code 
 Tools exist for testing 
 Tools exist for generating data 
 Testing processes improve the quality 
November 22 #sqlsat355 nd, 2014
http://www.red-gate.com/products/sql-development/sql-test/ 
http://tsqlt.org/ 
http://sourceforge.net/projects/tsqlunit/ 
http://msdn.microsoft.com/en-us/library/dd172118(v=vs.100).aspx (VS 2010) 
http://blogs.msdn.com/b/ssdt/archive/2012/12/07/getting-started-with-sql-server-database-unit- 
http://msdn.microsoft.com/en-us/library/jj851200(v=vs.103).aspx (VS 2012) 
http://channel9.msdn.com/Events/Visual-Studio/Launch-2013/QE107 (VS 2013) 
http://msdn.microsoft.com/it-it/library/dn383992.aspx (Article on CI) 
http://msdn.microsoft.com/en-us/library/jj907294.aspx (DLM) 
http://en.wikipedia.org/wiki/Unit_testing 
https://www.simple-talk.com/sql/t-sql-programming/getting-started-testing-databases-with-tsqlt/ 
#sqlsatParma 
Resources 
testing-in-ssdt.aspx (SSDT) 
http://utplsql.sourceforge.net/ (PL-SQL) 
https://github.com/chrisoldwood/SS-Unit 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
Q&A 
 Questions? 
November 22 #sqlsat355 nd, 2014
#sqlsatParma 
THANKS! 
#sqlsatParma 
#sqlsat355 
November 22 #sqlsat355 nd, 2014

Weitere ähnliche Inhalte

Andere mochten auch

[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON support
[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON support[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON support
[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON supportAlessandro Alpi
 
Oraciones simples con solucionario (ppt)
Oraciones simples con solucionario (ppt)Oraciones simples con solucionario (ppt)
Oraciones simples con solucionario (ppt)CastilloAguilera
 
Educational managment task_2
Educational managment task_2Educational managment task_2
Educational managment task_2alexandersaa2013
 
Quick intro sul Source Control su SQL Server
Quick intro sul Source Control su SQL ServerQuick intro sul Source Control su SQL Server
Quick intro sul Source Control su SQL ServerAlessandro Alpi
 
Cwit interview
Cwit interviewCwit interview
Cwit interviewakhtarsaad
 
Lietuviai praranda laisvę
Lietuviai praranda laisvęLietuviai praranda laisvę
Lietuviai praranda laisvęErika Bražienė
 
[ITA] SQL Saturday 264 - Put databases in ALM backgrounds
[ITA] SQL Saturday 264 - Put databases in ALM backgrounds[ITA] SQL Saturday 264 - Put databases in ALM backgrounds
[ITA] SQL Saturday 264 - Put databases in ALM backgroundsAlessandro Alpi
 
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databasesAlessandro Alpi
 
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...Alessandro Alpi
 
[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source control
[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source control[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source control
[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source controlAlessandro Alpi
 
#DOAW16 - DevOps@work Roma 2016 - Databases under source control
#DOAW16 - DevOps@work Roma 2016 - Databases under source control#DOAW16 - DevOps@work Roma 2016 - Databases under source control
#DOAW16 - DevOps@work Roma 2016 - Databases under source controlAlessandro Alpi
 

Andere mochten auch (17)

[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON support
[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON support[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON support
[Ita] Sql Saturday 462 Parma - Sql Server 2016 JSON support
 
Oraciones simples con solucionario (ppt)
Oraciones simples con solucionario (ppt)Oraciones simples con solucionario (ppt)
Oraciones simples con solucionario (ppt)
 
Educational managment task_2
Educational managment task_2Educational managment task_2
Educational managment task_2
 
Gordonas sausio
Gordonas sausioGordonas sausio
Gordonas sausio
 
Quick intro sul Source Control su SQL Server
Quick intro sul Source Control su SQL ServerQuick intro sul Source Control su SQL Server
Quick intro sul Source Control su SQL Server
 
Cwit interview
Cwit interviewCwit interview
Cwit interview
 
Lietuviai praranda laisvę
Lietuviai praranda laisvęLietuviai praranda laisvę
Lietuviai praranda laisvę
 
Acting In The Digital Age Workshop @UMFF
Acting In The Digital Age Workshop @UMFFActing In The Digital Age Workshop @UMFF
Acting In The Digital Age Workshop @UMFF
 
Activity 3
Activity 3Activity 3
Activity 3
 
[ITA] SQL Saturday 264 - Put databases in ALM backgrounds
[ITA] SQL Saturday 264 - Put databases in ALM backgrounds[ITA] SQL Saturday 264 - Put databases in ALM backgrounds
[ITA] SQL Saturday 264 - Put databases in ALM backgrounds
 
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
 
Lista 2 - geografia
Lista 2 - geografiaLista 2 - geografia
Lista 2 - geografia
 
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
DevOpsHeroes 2016 - Realizzare Continouous Integration con SQL Server e Visua...
 
[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source control
[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source control[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source control
[ITA] Sql Saturday 355 in Parma - New SQL Server databases under source control
 
#DOAW16 - DevOps@work Roma 2016 - Databases under source control
#DOAW16 - DevOps@work Roma 2016 - Databases under source control#DOAW16 - DevOps@work Roma 2016 - Databases under source control
#DOAW16 - DevOps@work Roma 2016 - Databases under source control
 
Directing teaching resume 2015
Directing teaching resume 2015Directing teaching resume 2015
Directing teaching resume 2015
 
Lista 5
Lista 5Lista 5
Lista 5
 

Mehr von Alessandro Alpi

Mvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops worldMvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops worldAlessandro Alpi
 
Digital warriors 2020 - Smart?
Digital warriors 2020 - Smart?Digital warriors 2020 - Smart?
Digital warriors 2020 - Smart?Alessandro Alpi
 
Sql Wars - SQL the attack of the Clones and the rebellion of the Containers
Sql Wars - SQL the attack of the Clones and the rebellion of the Containers Sql Wars - SQL the attack of the Clones and the rebellion of the Containers
Sql Wars - SQL the attack of the Clones and the rebellion of the Containers Alessandro Alpi
 
Sql Wars - SQL Clone vs Docker Containers
Sql Wars - SQL Clone vs Docker Containers Sql Wars - SQL Clone vs Docker Containers
Sql Wars - SQL Clone vs Docker Containers Alessandro Alpi
 
Doaw2020 - Dalla produzione alla QA, provisioning su SQL Server
Doaw2020 - Dalla produzione alla QA, provisioning su SQL ServerDoaw2020 - Dalla produzione alla QA, provisioning su SQL Server
Doaw2020 - Dalla produzione alla QA, provisioning su SQL ServerAlessandro Alpi
 
Wpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero teamWpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero teamAlessandro Alpi
 
Sql start!2019 Migliorare la produttività per lo sviluppo su SQL Server
Sql start!2019 Migliorare la produttività per lo sviluppo su SQL ServerSql start!2019 Migliorare la produttività per lo sviluppo su SQL Server
Sql start!2019 Migliorare la produttività per lo sviluppo su SQL ServerAlessandro Alpi
 
Configuration e change management con Disciplined Agile Framework
Configuration e change management con Disciplined Agile FrameworkConfiguration e change management con Disciplined Agile Framework
Configuration e change management con Disciplined Agile FrameworkAlessandro Alpi
 
Basta poco per distruggere DevOps
Basta poco per distruggere DevOpsBasta poco per distruggere DevOps
Basta poco per distruggere DevOpsAlessandro Alpi
 
Automatizzare il processo di link dei database con redgate source control
Automatizzare il processo di link dei database con redgate source controlAutomatizzare il processo di link dei database con redgate source control
Automatizzare il processo di link dei database con redgate source controlAlessandro Alpi
 
Sql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DB
Sql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DBSql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DB
Sql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DBAlessandro Alpi
 
Sql Saturday a Pordenone - Sql Server journey, da dev a ops
Sql Saturday a Pordenone - Sql Server journey, da dev a opsSql Saturday a Pordenone - Sql Server journey, da dev a ops
Sql Saturday a Pordenone - Sql Server journey, da dev a opsAlessandro Alpi
 
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON supportAlessandro Alpi
 

Mehr von Alessandro Alpi (13)

Mvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops worldMvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops world
 
Digital warriors 2020 - Smart?
Digital warriors 2020 - Smart?Digital warriors 2020 - Smart?
Digital warriors 2020 - Smart?
 
Sql Wars - SQL the attack of the Clones and the rebellion of the Containers
Sql Wars - SQL the attack of the Clones and the rebellion of the Containers Sql Wars - SQL the attack of the Clones and the rebellion of the Containers
Sql Wars - SQL the attack of the Clones and the rebellion of the Containers
 
Sql Wars - SQL Clone vs Docker Containers
Sql Wars - SQL Clone vs Docker Containers Sql Wars - SQL Clone vs Docker Containers
Sql Wars - SQL Clone vs Docker Containers
 
Doaw2020 - Dalla produzione alla QA, provisioning su SQL Server
Doaw2020 - Dalla produzione alla QA, provisioning su SQL ServerDoaw2020 - Dalla produzione alla QA, provisioning su SQL Server
Doaw2020 - Dalla produzione alla QA, provisioning su SQL Server
 
Wpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero teamWpc2019 - Distruggere DevOps, la storia di un vero team
Wpc2019 - Distruggere DevOps, la storia di un vero team
 
Sql start!2019 Migliorare la produttività per lo sviluppo su SQL Server
Sql start!2019 Migliorare la produttività per lo sviluppo su SQL ServerSql start!2019 Migliorare la produttività per lo sviluppo su SQL Server
Sql start!2019 Migliorare la produttività per lo sviluppo su SQL Server
 
Configuration e change management con Disciplined Agile Framework
Configuration e change management con Disciplined Agile FrameworkConfiguration e change management con Disciplined Agile Framework
Configuration e change management con Disciplined Agile Framework
 
Basta poco per distruggere DevOps
Basta poco per distruggere DevOpsBasta poco per distruggere DevOps
Basta poco per distruggere DevOps
 
Automatizzare il processo di link dei database con redgate source control
Automatizzare il processo di link dei database con redgate source controlAutomatizzare il processo di link dei database con redgate source control
Automatizzare il processo di link dei database con redgate source control
 
Sql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DB
Sql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DBSql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DB
Sql saturday parma 2017 (#sqlsat675) - Deep space Cosmos DB
 
Sql Saturday a Pordenone - Sql Server journey, da dev a ops
Sql Saturday a Pordenone - Sql Server journey, da dev a opsSql Saturday a Pordenone - Sql Server journey, da dev a ops
Sql Saturday a Pordenone - Sql Server journey, da dev a ops
 
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support
[Eng] Sql Saturday TorinoExpo - Sql Server 2016 JSON support
 

Kürzlich hochgeladen

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Kürzlich hochgeladen (20)

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

[ENG] Sql Saturday 355 in Parma - Test your SQL Server databases

  • 1. #sqlsatParma Testing your databases Alessandro Alpi @suxstellino www.alessandroalpi.net November 22 #sqlsat355 nd, 2014
  • 2. #sqlsatParma Sponsors November 22 #sqlsat355 nd, 2014
  • 3. #sqlsatParma Organizers November 22 #sqlsat355 nd, 2014
  • 4. #sqlsatParma About me  SQL Server MVP since 2008  Microsoft Certified  blogs:  [ITA] http://blogs.dotnethell.it/suxstellino  [ENG] http://suxstellino.wordpress.com/  More details on:  http://www.alessandroalpi.net November 22 #sqlsat355 nd, 2014
  • 5. #sqlsatParma Agenda  ALM/DLM concepts  Unit Testing concepts  Why Unit Testing on databases  Unit Testing frameworks  Unit Testing solutions  Conclusions  Q&A November 22 #sqlsat355 nd, 2014
  • 6. ALM is the product lifecycle management (governance, development, and maintenance) of application software. It encompasses requirements management, software architecture, computer programming, software testing, software maintenance, change management, project management, and release management. (source: Wikipedia) #sqlsatParma ALM definition November 22 #sqlsat355 nd, 2014
  • 7. #sqlsatParma Why ALM?  Breaking the team barriers (integration)  Release high quality software  Release software in quickly way  Customer satisfaction  Improved work organization  Monitoring and tracking the activities  Improved code (clear and easy to read) November 22 #sqlsat355 nd, 2014
  • 8. #sqlsatParma How to reach the best Quality?  Continuous Integration!  DEVELOP  SEND  BUILD  TEST November 22 #sqlsat355 nd, 2014
  • 9. DLM – Database lifecycle management DLM is a comprehensive approach to managing the database schema, data, and metadata for a database application. DLM begins with discussion of project design and intent, continues with database develop, test, build, deploy, maintain, monitor, and backup activities, and ends with data archive. (source: TechNet) #sqlsatParma November 22 #sqlsat355 nd, 2014
  • 10. In computer programming, unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures are tested to determine if they are fit for use. The primary purpose of this approach is to find out bugs and prevent regressions. (source: Wikipedia) #sqlsatParma Unit testing November 22 #sqlsat355 nd, 2014
  • 11. #sqlsatParma Unit testing – Why? November 22 #sqlsat355 nd, 2014
  • 12. #sqlsatParma Unit testing – Why?  Mission-critical business functionality  Evolutionary development  Usage of mock/fake objects  We’re missing bugs  We’re missing potential regressions November 22 #sqlsat355 nd, 2014
  • 13. «Fix bugs as soon as you find them» #sqlsatParma Then..  Unfixed bugs camouflage other bugs  Unfixed bugs suggest quality isn’t important  Discussing unfixed bugs is a waste of time  Unfixed bugs lead to duplicate effort November 22 #sqlsat355 nd, 2014
  • 14. #sqlsatParma Lesson learned..  Unfixed bugs lead to unreliable metrics  Unfixed bugs distract the entire team  Unfixed bugs hinder short-notice releases  Unfixed bugs lead to inaccurate estimates  Fixing familiar code is easier  Fixing a bug today costs less than tomorrow November 22 #sqlsat355 nd, 2014
  • 15.  Executing the code on a copy of production data  Manual testing  Some test cases forgotten as the code changes.  Some test is made on structures with “test-unrelated” constraints which could break the test #sqlsatParma Unit testing – What we usually do?  T-SQL debug for checking variable values  PRINT, PRINT, SELECT…  Not repeatable and human errors (subjectivity) November 22 #sqlsat355 nd, 2014
  • 16. #sqlsatParma Unit testing – What do I test?  Calculations in procedures and functions  Constraints (schema)  Edge cases of data DML  Expected behavior of data DML  Error Handling  Security  Standards November 22 #sqlsat355 nd, 2014
  • 17. #sqlsatParma Unit testing – What can we use?  Frameworks  tSQLt  tSQLUnit  SQLCop  SS-Unit  Tools  SQLTest by Red-Gate (tSQLt + SQLCop)  Unit test project with Visual Studio November 22 #sqlsat355 nd, 2014
  • 18. #sqlsatParma Unit testing – tSQLt  Free framework (open source)  T-SQL  Requires SQLCLR to be enabled  Includes common assertions  Self-contained tests  Isolated transactions  Versatile  Similar to xUnit November 22 #sqlsat355 nd, 2014
  • 19. #sqlsatParma Unit testing – tSQLt structures  Built-in  tsqlt schema  Classes  Group of stored procedures (tests)  Model  Assemble (create fakes)  Act (apply logics)  Assert (verify results)  Conventions  Naming: test* November 22 #sqlsat355 nd, 2014
  • 20. #sqlsatParma DEMO 1 tSQLt and Red-Gate SQL Test + November 22 #sqlsat355 nd, 2014
  • 21. #sqlsatParma Unit testing – Visual Studio  Visual Studio Data Tools  Unit test projects (created by template)  .Net + T-SQL  Supported also in VS 2013  Integrated Test UI (Test Explorer)  UI for test conditions  Pre/Post test scripts November 22 #sqlsat355 nd, 2014
  • 22. #sqlsatParma DEMO 2 Visual Studio database unit testing projects + November 22 #sqlsat355 nd, 2014
  • 23. tSQLUnit #sqlsatParma Unit testing – tSQLUnit  Free framework (open source)  T-SQL and SSMS  Self-contained tests  Isolated transactions  Versatile  Setup and reset  Similar to xUnit November 22 #sqlsat355 nd, 2014
  • 24. tSQLUnit #sqlsatParma Unit testing – tSQLUnit structures  TestSuites  Is the name after ut_ prefix  Groups of procedures  User defined test (prefix ut_)  ut_TestSuiteName_WhatToDo  Built-in  tsu_ procedures  Fixtures  _setup procedures  ut_TestSuiteName_setup  _teardown procedures  ut_TestSuiteName_teardown  They execute for each test in the suite November 22 #sqlsat355 nd, 2014
  • 25. #sqlsatParma DEMO 3 tSQLUnit in SQL Server Management Studio + tSQLUnit November 22 #sqlsat355 nd, 2014
  • 26. #sqlsatParma Features comparison – SQL Test  Pros  SSMS integration  Class execution  Messages and icons (UI)  T-SQL oriented  Self-contained  Supports tSQLt and SQLCop  Cons  Ui to be improved  Installs a set of objects  Needs SQLCLR  Needs TRUSTWORTHY ON November 22 #sqlsat355 nd, 2014
  • 27. #sqlsatParma Features comparison – Visual Studio  Pros  Visual Studio   Future support of project templates  Improved UI and designers  Does not need to add objects to database  Cons  Test project is not so comfortable  Test framework is not written in T-SQL  Out of SSMS (is this really a Con? )  Different approaches on past VS versions November 22 #sqlsat355 nd, 2014
  • 28. tSQLUnit #sqlsatParma Features comparison – tSQLUnit  Pros  T-SQL oriented  Based on well known xUnit framework  Does not need SQLCLR  Open source  Cons  No UI  Installs a set of objects on the database  Poor T-SQL based documentation November 22 #sqlsat355 nd, 2014
  • 29. #sqlsatParma Conclusions  There is no excuse for NOT testing like any other piece of code  Tools exist for testing  Tools exist for generating data  Testing processes improve the quality November 22 #sqlsat355 nd, 2014
  • 30. http://www.red-gate.com/products/sql-development/sql-test/ http://tsqlt.org/ http://sourceforge.net/projects/tsqlunit/ http://msdn.microsoft.com/en-us/library/dd172118(v=vs.100).aspx (VS 2010) http://blogs.msdn.com/b/ssdt/archive/2012/12/07/getting-started-with-sql-server-database-unit- http://msdn.microsoft.com/en-us/library/jj851200(v=vs.103).aspx (VS 2012) http://channel9.msdn.com/Events/Visual-Studio/Launch-2013/QE107 (VS 2013) http://msdn.microsoft.com/it-it/library/dn383992.aspx (Article on CI) http://msdn.microsoft.com/en-us/library/jj907294.aspx (DLM) http://en.wikipedia.org/wiki/Unit_testing https://www.simple-talk.com/sql/t-sql-programming/getting-started-testing-databases-with-tsqlt/ #sqlsatParma Resources testing-in-ssdt.aspx (SSDT) http://utplsql.sourceforge.net/ (PL-SQL) https://github.com/chrisoldwood/SS-Unit November 22 #sqlsat355 nd, 2014
  • 31. #sqlsatParma Q&A  Questions? November 22 #sqlsat355 nd, 2014
  • 32. #sqlsatParma THANKS! #sqlsatParma #sqlsat355 November 22 #sqlsat355 nd, 2014

Hinweis der Redaktion

  1. Note that the cost of bugs rises. We know this. The earlier we find issues, the better. We can see from this survey that the cost of bugs rises dramatically as we get closer to the client.
  2. Note that the cost of bugs rises. We know this. The earlier we find issues, the better. We can see from this survey that the cost of bugs rises dramatically as we get closer to the client.