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.

Test-Driven SQL

This session looks at applying the same principles and disciplines used in other areas of system development to tame the ever increasing complexity that has arisen from the maturity of the RDBMS. To show how easy it can be to apply TDD/Unit Testing to SQL development, part of the talk will involve coding up a procedure in a test-first manner using a freely available T-SQL based test framework.

  • Be the first to comment

  • Be the first to like this

Test-Driven SQL

  1. 1. Test-Driven SQLTest-Driven SQL Chris OldwoodChris Oldwood Agile on the Beach 2014Agile on the Beach 2014 @chrisoldwood / /
  2. 2. SELECT * FROM ScopeSELECT * FROM Scope  PreamblePreamble  SQL Unit TestingSQL Unit Testing  TDD by ExampleTDD by Example  QuestionsQuestions
  3. 3. SQL Is Just Code…SQL Is Just Code…
  4. 4. ……MostlyMostly
  5. 5. SQL Unit TestingSQL Unit Testing
  6. 6. Functional TestingFunctional Testing Tests should verify the publiclyTests should verify the publicly observable behaviour not theobservable behaviour not the choice of implementationchoice of implementation
  7. 7. Development SandboxDevelopment Sandbox  IsolationIsolation  Fast feedbackFast feedback  DeterministicDeterministic  ToolingTooling
  8. 8. Example TestExample Test create procedure test._@TestSetUp@_Something as -- common arrangement go create procedure test._@Test@_Something_ShouldDoAnotherThing as declare @arrangement varchar(100) = 'arrangement'; declare @expected int = 42; declare @actual int = public.ActOnArrangement(); exec ssunit.AssertIntegerEqualTo @expected, @actual; go exec ssunit.RunTests;
  9. 9. Example FeatureExample Feature Produce a report showing howProduce a report showing how many bugs each developer hasmany bugs each developer has assigned to them.assigned to them.
  10. 10. Questions?Questions?
  11. 11. Want to Know More?Want to Know More? BlogBlog http://chrisoldwood.blogspot.com SQL-Unit / SQL-Cop / sql2doxygenSQL-Unit / SQL-Cop / sql2doxygen http://www. @chrisoldwood / /