Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

1,116 views

Published on

Unit testing is a good practice to follow also in a database development environment. It allows to realize and finalize the Continuous Integration process on our database and It makes all the development more reliable and consistent just before deployment. We can use some interesting frameworks when testing, and we will speak about installing and executing them.

Published in: Software
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/diVYI ◀ ◀ ◀ ◀
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/diVYI ◀ ◀ ◀ ◀
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

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

  1. 1. #sqlsatParma Testing your databases Alessandro Alpi @suxstellino www.alessandroalpi.net November 22 #sqlsat355 nd, 2014
  2. 2. #sqlsatParma Sponsors November 22 #sqlsat355 nd, 2014
  3. 3. #sqlsatParma Organizers November 22 #sqlsat355 nd, 2014
  4. 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. 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. 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. 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. 8. #sqlsatParma How to reach the best Quality?  Continuous Integration!  DEVELOP  SEND  BUILD  TEST November 22 #sqlsat355 nd, 2014
  9. 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. 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. 11. #sqlsatParma Unit testing – Why? November 22 #sqlsat355 nd, 2014
  12. 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. 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. 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. 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. 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. 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. 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. 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. 20. #sqlsatParma DEMO 1 tSQLt and Red-Gate SQL Test + November 22 #sqlsat355 nd, 2014
  21. 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. 22. #sqlsatParma DEMO 2 Visual Studio database unit testing projects + November 22 #sqlsat355 nd, 2014
  23. 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. 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. 25. #sqlsatParma DEMO 3 tSQLUnit in SQL Server Management Studio + tSQLUnit November 22 #sqlsat355 nd, 2014
  26. 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. 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. 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. 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. 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. 31. #sqlsatParma Q&A  Questions? November 22 #sqlsat355 nd, 2014
  32. 32. #sqlsatParma THANKS! #sqlsatParma #sqlsat355 November 22 #sqlsat355 nd, 2014

×