SlideShare a Scribd company logo
[Database unit tests]
(in the SQL Server world)
[Marian Chicu]
[Centric IT Romania]
[20th of April 2013]
Who am I?
• Development DBA @ Centric IT Romania
• Previously at ThinSlices and Premium
Software
• Working experience with SQL Server 2000
-> 2008 R2
• http://dba.stackexchange.com/users/418/
• http://www.linkedin.com/in/marianchicu/
Agenda
• Definition of unit testing
• Test driven development concepts
• Who cares?
• Benefits of unit testing
• Cost of unit testing
• Choosing what to test
• Demo with code
• Q&A (optional)
What is unit testing?
“In computer programming, unit testing is a
method by which individual units of source
code are tested to determine if they are fit
for use.
Intuitively, one can view a unit as the
smallest testable part of an application.”
What is unit testing?
• Unit testing is a lot like going to the gym
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql server world
Early reactions
Developers:
• I don’t test. I write code. I create.
Early reactions
Managers:
• I don’t want to pay developers to test, that’s why
we have testers!
The beginnings
XUnit = {SUnit, JUnit, CppUnit, NUnit, ...}
XUnit Architecture
Test case
This is the most elemental class. All unit
tests are inherited from here.
XUnit Architecture
Test suites
A test suite is a set of tests that all share the
same fixture. The order of the tests shouldn't
matter.
XUnit Architecture
Test fixtures
A test fixture (also known as a test context)
is the set of preconditions or state needed to
run a test. The developer should set up a
known good state before the tests, and
return to the original state after the tests.
XUnit Architecture
Test execution
• Setup – prepare test data
• Body of test - Here we make all the tests
• Assertions - An assertion is a function that
verifies the behavior of the unit under test.
XUnit Architecture
Test execution
• Assertions - Failure of an assertion typically
throws an exception, aborting the execution
of the current test.
• Teardown - we should clean up our 'world'
to not disturb other tests or code
Who cares? Why do they care?
• Developers
Who cares? Why do they care?
• Developers
Who cares? Why do they care?
• DBAs
Who cares? Why do they care?
• DBAs
Who cares? Why do they care?
• QA engineers / Testers
Who cares? Why do they care?
• QA engineers / Testers
What is a unit test?
• Code testing code
What is the ideal unit test?
• easy to roll out
• easy to roll out
What is the ideal unit test?
• easy to maintain
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql server world
What is the ideal unit test?
• run fast
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql server world
The old way
• Print
• Select statements all over
• Console.WriteLine
• Create executable
The new way
• Visual Studio database project
• Add unit test to relevant procedures
• Have all tests green! Or not .
Benefits
• Find problems early
Benefits
• Facilitates change
Benefits
• Simplifies integration
Benefits
• Documentation
The cost $$
The time spent actually writing unit tests in
the first place.
The time spent fixing and updating unit tests.
The tendency to avoid improving and
refactoring code.
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql server world
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql server world
Real Benefits
• Thinking-driven development
• Questions-driven development
Test driven development
Some key concepts
Test driven development
The test system should support the
developer, not the other way around.
A developer must be able to create a new
test in under 10 minutes.
Test driven development
The test suite should be capable of running
hundreds of tests in minutes (not hours).
What to test?
Complex queries need better documentation
Complex queries need possible rewrites
(performance tuning, anyone? )
Demo Unit test
Coding demo
Demo Unit test
Tools
• Visual Studio 2010 Premium
• SQL Server 2008 R2
SSIS Unit test runner
• A hidden gem
• XML based
•Complex modules are more difficult to change if the requirements have changed
Database unit testing tools
• tSQLt – “The Database Unit Testing
Framework for SQL Server” (.NET)
• DBTestUnit – “free database unit testing
framework for .NET – currently supporting
MS SQL, MySQL and Oracle.”
• T.S.T. the T-SQL Test Tool – a testing API
(TSQL)
References:
Alex Kuznetsov’s blog – SimpleTalk and
SQLBlog
The RedGate Guide to SQL Server Team
Based Development - Phil Factor & co
What is the #1 Benefit of TDD? - Gil
Zilberfeld
References:
XUnit – Martin Fowler
Verifying Database Code by Using Unit Tests
– MSDN
Database Unit Testing with Team Edition for
Database Professionals - MSDN
References:
PluralSight courses
• Visual Studio 2010 Database Projects
• Test First Development
• Unit Testing with MSTest
Selective Unit Testing – Costs and Benefits -
Steven Sanderson
Unit Testing Myths and Practices - Tom
Fischer (on SimpleTalk)
Q&A
[Database unit tests]
[Marian Chicu]
[Centric IT Romania]
[20th of April 2013]
Please fill in your evaluation form!

More Related Content

PDF
Database development unit test with tSQLt
PPTX
The Key Components of Adopting CI The OpenStack Way
PPT
Walking Skeleton
PPTX
Test Driven Development - a Practitioner’s Perspective
PPTX
Brown bag tfs best practices - slide share
PDF
What is this agile thing anyway
POTX
Functional Tests. PHP Unconf 2016
PPTX
Introduction to SoapUI day 1
Database development unit test with tSQLt
The Key Components of Adopting CI The OpenStack Way
Walking Skeleton
Test Driven Development - a Practitioner’s Perspective
Brown bag tfs best practices - slide share
What is this agile thing anyway
Functional Tests. PHP Unconf 2016
Introduction to SoapUI day 1

What's hot (19)

PPTX
Unit Testing in Swift
PPTX
Avoiding test hell
PDF
MBLTDev15: Brigit Lyons, Soundcloud
PDF
Olli-Pekka Puolitaival - Model-Based Testing for Integration Testing in Real ...
PPTX
Testing
PPTX
Level Up Your Salesforce Unit Testing
PDF
КОСТЯНТИН НАТАЛУХА «Setup and run automated test framework for Android applic...
PDF
T23 HTML5 Security Testing at Spotify
PPTX
200808 AIM Walking Skeleton
PPTX
Leandro Melendez - Switching Performance Left & Right
PPTX
Get Testing with tSQLt - SQL In The City Workshop 2014
PDF
CNUG TDD June 2014
PDF
Introduction to Automated Testing
PPTX
Build Tests to Build Websites
PPTX
Part1 my
PPTX
ОЛЕКСІЙ ОСТАПОВ «Найкрутіші особливості автоматизації на Playwright Python» K...
PPTX
Increase selenium tests stability via java script
PPTX
Unit Testing and Tools
PPTX
Unit Testing and Tools - ADNUG
Unit Testing in Swift
Avoiding test hell
MBLTDev15: Brigit Lyons, Soundcloud
Olli-Pekka Puolitaival - Model-Based Testing for Integration Testing in Real ...
Testing
Level Up Your Salesforce Unit Testing
КОСТЯНТИН НАТАЛУХА «Setup and run automated test framework for Android applic...
T23 HTML5 Security Testing at Spotify
200808 AIM Walking Skeleton
Leandro Melendez - Switching Performance Left & Right
Get Testing with tSQLt - SQL In The City Workshop 2014
CNUG TDD June 2014
Introduction to Automated Testing
Build Tests to Build Websites
Part1 my
ОЛЕКСІЙ ОСТАПОВ «Найкрутіші особливості автоматизації на Playwright Python» K...
Increase selenium tests stability via java script
Unit Testing and Tools
Unit Testing and Tools - ADNUG
Ad

Similar to Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql server world (20)

PPTX
Lean-Agile Development with SharePoint - Bill Ayers
PDF
A data driven etl test framework sqlsat madison
PPTX
Reliable mobile test automation
PPTX
Tools for Software Testing
PDF
Cloud-based Test Microservices JavaOne 2014
PPTX
Automation at Philips Healthcare
PDF
Introduction to-automated-testing
PDF
TDD and Related Techniques for Non Developers (2012)
PDF
Unit Testing in JavaScript
PPTX
Effective .NET Core Unit Testing with SQLite and Dapper
PPTX
Effective .NET Core Unit Testing with SQLite and Dapper
PPTX
Performance Tuning in the Trenches
PPT
1.microsoft visual studio 2010 test manager
PPTX
A Day in the Life: Developer Enhancements with Visual Studio 2012
PPTX
Aqa talk denys zaitas
PPTX
Test Automation Architecture That Works by Bhupesh Dahal
PDF
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
PPTX
QAorHighway2016
PPTX
Test automation proposal
PDF
Improving Batch-Process Testing Techniques with a Domain-Specific Language
Lean-Agile Development with SharePoint - Bill Ayers
A data driven etl test framework sqlsat madison
Reliable mobile test automation
Tools for Software Testing
Cloud-based Test Microservices JavaOne 2014
Automation at Philips Healthcare
Introduction to-automated-testing
TDD and Related Techniques for Non Developers (2012)
Unit Testing in JavaScript
Effective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and Dapper
Performance Tuning in the Trenches
1.microsoft visual studio 2010 test manager
A Day in the Life: Developer Enhancements with Visual Studio 2012
Aqa talk denys zaitas
Test Automation Architecture That Works by Bhupesh Dahal
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
QAorHighway2016
Test automation proposal
Improving Batch-Process Testing Techniques with a Domain-Specific Language
Ad

More from Codecamp Romania (20)

PDF
Cezar chitac the edge of experience
PPTX
Cloud powered search
PPTX
Business analysis techniques exercise your 6-pack
PPTX
Bpm company code camp - configuration or coding with pega
PPT
Andrei prisacaru takingtheunitteststothedatabase
PPTX
Agility and life
PPTX
2015 dan ardelean develop for windows 10
PDF
The bigrewrite
PDF
The case for continuous delivery
PPTX
Stefan stolniceanu spritekit, 2 d or not 2d
PPTX
Sizing epics tales from an agile kingdom
PPTX
Scale net apps in aws
PPTX
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
PPTX
Parallel & async processing using tpl dataflow
PDF
Material design screen transitions in android
PDF
Kickstart your own freelancing career
PDF
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
PDF
Ecma6 in the wild
PPTX
Diana antohi me against myself or how to fail and move forward
Cezar chitac the edge of experience
Cloud powered search
Business analysis techniques exercise your 6-pack
Bpm company code camp - configuration or coding with pega
Andrei prisacaru takingtheunitteststothedatabase
Agility and life
2015 dan ardelean develop for windows 10
The bigrewrite
The case for continuous delivery
Stefan stolniceanu spritekit, 2 d or not 2d
Sizing epics tales from an agile kingdom
Scale net apps in aws
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Parallel & async processing using tpl dataflow
Material design screen transitions in android
Kickstart your own freelancing career
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Ecma6 in the wild
Diana antohi me against myself or how to fail and move forward

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
A Presentation on Artificial Intelligence
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PPTX
Programs and apps: productivity, graphics, security and other tools
Spectroscopy.pptx food analysis technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The Rise and Fall of 3GPP – Time for a Sabbatical?
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Assigned Numbers - 2025 - Bluetooth® Document
A Presentation on Artificial Intelligence
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
Programs and apps: productivity, graphics, security and other tools

Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql server world

Editor's Notes

  • #2: "Unit testing is a well-understood concept in application development, but the database community has not yet embraced the advantages and strategies of this approach."This is a quote from an older MSDN whitepaper (march 2007) regarding unit testing in the SQL Server world. 6 years later I've found the situation is pretty similar, with many developers that write database code not really using this helpful methodology.
  • #3: I miss you all!- 10 years experience (SQL Server 2000 -> 2k8 R2);- I like to learn & share technical info in the SO world (mostly on DBA.StackExchange.com)- don't tell my employer ;))! I do it only from home, really really!!- I'd like to see a SQL Server user group started (even if only for beers together, socializing should be mandatory in our field, we're so few);- Also a general database professionals group would be nice;Personal info:- I like reading about science stuff, IT security, psychology (Dan Ariely, PsyBlog);- Playing games on my PlayStation, playing poker, going to ski, airsoft;- as my friends already know, don't really like driving :-);
  • #6: You know it is good for you, all the arguments make sense, so you start working out. There's an initial rush, which is great, but after a few days you start to wonder if it is worth the trouble. You're taking an hour out of your day to change your clothes and run on a hamster wheel and you're not sure you're really gaining anything other than sore legs and arms.Then, after maybe one or two weeks, just as the soreness is going away, a Big Deadline begins approaching. You need to spend every waking hour trying to get "useful" work done, so you cut out extraneous stuff, like going to the gym. You fall out of the habit, and by the time Big Deadline is over, you're back to square one. If you manage to make it back to the gym at all, you feel just as sore as you were the first time you went.
  • #7: You know it is good for you, all the arguments make sense, so you start working out. There's an initial rush, which is great, but after a few days you start to wonder if it is worth the trouble. You're taking an hour out of your day to change your clothes and run on a hamster wheel and you're not sure you're really gaining anything other than sore legs and arms.Then, after maybe one or two weeks, just as the soreness is going away, a Big Deadline begins approaching. You need to spend every waking hour trying to get "useful" work done, so you cut out extraneous stuff, like going to the gym. You fall out of the habit, and by the time Big Deadline is over, you're back to square one. If you manage to make it back to the gym at all, you feel just as sore as you were the first time you went.
  • #8: There's a misperception that testing belongs solely in the domain of QA. Developers are coders, and can't write tests.It's very hard to determine the value of test code.
  • #9: Management doesn't really understand what unit testing really is, or why it has real intrinsic value to them.Management tends to be more concerned with rapid product delivery, and (incorrectly) sees unit testing as counterproductive to that goal.There's a common misperception that management will have to spend money to do unit testing correctly, despite the fact that the tools are freely available. (There is, of course, the developer ramp up time to consider, but it's not really prohibitive.)
  • #10: XUnit is the family name given to bunch of testing frameworks that have become widely known amongst software developers. The name is a derivation of JUnit the first of these to be widely known. Siblings -> CppUnit, Nunit.The real root SUnit: Smalltalk community, Kent Beck was a big fan of automated testing at the heart of software development.The focus was on making it easy for programmers to define the tests using their regular Smalltalk environment, and then to run either a subset or a full set of tests quickly. Kent and his followers would run unit tests after every change to the system going through a rapid edit and test cycle in the Smalltalk IDE.
  • #11: This is were a set of unit tests start (Test a Search stored procedure) -> several tests that fulfill this idea.
  • #12: Test suite = (setup + teardown for the whole package) + tests (including their setup and teardowns)
  • #13: Setup + teardown for the UNIT TEST
  • #14: The setup() and teardown() methods serve to initialize and clean up test fixtures.
  • #15: The setup() and teardown() methods serve to initialize and clean up test fixtures.
  • #16: - bright individuals that get a new technology very fast (new languages, new platforms, new tools are acquired immediately as they appear);- in constant change (evolve continuously) - very rarely, mostly in big corporations, we see individuals that stay on the same technology for decades;- very good at writing complex database code (reports, searches, financial calculations);- sometimes want to avoid writing SQL code, they want to use an ORM (which is cool, unless you debug a 2 page query);- really a job of "Jack of all trades" (languages HTML, JS, C#, VB, CSS, ORMs, platforms for logging, for build, for source control, ..etc);- SQL is only a tool in their large handbag of tools;- think in objects or in procedures, butnot all the times get the "set way of thinking";
  • #17: - don't care much about configuration, settings (integration testing -> files needed, settings that are changing from server to server -> connection strings, etc);- connections strings are ok?- files for input and output are existing?- want to make sure that functionality doesn't change (replace some LINQ with pure SQL and make sure the result is the same) -> transfer .net unit tests in db unit tests;- same approach as for the app code: a dev that's used to write tests for his .net code, will likely want to do the same for the SQL code;- sentiment of insurance when all unit tests pass (want to extend that to the db code, too);- feel the database as part of the project, another layer that's close, not a different area altogether (we now have source control, projects, builds for the databases) - they might see the db code as just as close and familiar as .net code (as long as technologies are similar and only the language is different);
  • #18: - only in big companies;- there's no pure DBA job (in 99% of cases): sysadmin, SQL development, reports, BI implementations (ETL, aggregations);- usually they consider themselves the owner of the environment (which is not true):- everyone is owning the project (from the business owner, to the developer, QA, DevOps, DBA)- they do have the highest privileges on the db servers (but mostly because it's required, not because it's a playground);- like stability, because changes usually break things (deploys not really tested, system upgrades that don't go as expected (SP installation that breaks MS build and kills the server)) - lots of horror story especially in a 24/7 environment;- ugly ducklings (bad communication, no time, lack of insight in the app architecture, few people for many teams/environments/servers);- grumpy (see upper reasons);
  • #19: They do performance tuning (which means REWRITING a lot of code)most of them don't write SQL code for the application (but help review it or make it faster);When wearing the developer hat, they share the benefits;what fails in the db is seen as their responsibility (and it's false, because the DBA maintains the whole environment, not individual pieces of code), so they don’t mind another safety net;unit tests would add another layer of safety among many others (eyeballing, manual executions, load tests, unit tests, QA env, acceptance, production). This might alleviate future pain.
  • #20: - Represent the end user in the application development flow.-They do manual tests, automation, functionality, documentation, sometimes even talk to the customer to get facts.- sometimes even write code (load tests, automation of simple tests)- they have a hard life (sometimes one tester serves many developers, many apps, many environments, many clients)- interested in stability of the app;-they are the first real verification layer between the app and the real world;
  • #21: - unit tests are a kind of contract between the dev and the app code that the code is stable;- piece of mind that easy cases are caught (flaws in the logic, bad data for input/output, some unnecessary delays are avoided) - if there is enough coverage;- don't see a single unit test, but see the whole, if there is at least 50% code coverage (and it’s for the complex stuff), or some useful number, they are happy and sure the developer is covering his back for simple and obvious cases;- avoid unnecessary clicks for future :-);
  • #25: run fast, and make a difference: without them making changes and troubleshooting are more difficult.
  • #26: run fast, and make a difference: without them making changes and troubleshooting are more difficult.
  • #27: Nobody likes to wait
  • #28: Nobody likes to wait
  • #29: Without them making changes and troubleshooting are more difficult.
  • #30: How do you test a new procedure?@debug parameter -> generate prints all over (check the flow of the procedure)Take all parameters and make sample callsCheck if it works for general cases
  • #31: How do you test a new procedure?@debug parameter -> generate prints all over (check the flow of the procedure)Take all parameters and make sample callsCheck if it works for general cases
  • #32: Unit tests find problems early in the development cycle.In test-driven development (TDD), which is frequently used in both Extreme Programming and Scrum, unit tests are created before the code itself is written. When the tests pass, that code is considered complete. The same unit tests are run against that function frequently as the larger code base is developed either as the code is changed or via an automated process with the build. If the unit tests fail, it is considered to be a bug either in the changed code or the tests themselves. The unit tests then allow the location of the fault or failure to be easily traced. Since the unit tests alert the development team of the problem before handing the code off to testers or clients, it is still early in the development process.
  • #33: Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly (e.g., in regression testing). The procedure is to write test cases for all functionsand methods so that whenever a change causes a fault, it can be quickly identified and fixed.Readily available unit tests make it easy for the programmer to check whether a piece of code is still working properly.In continuous unit testing environments, through the inherent practice of sustained maintenance, unit tests will continue to accurately reflect the intended use of the executable and code in the face of any change. Depending upon established development practices and unit test coverage, up-to-the-second accuracy can be maintained.
  • #34: Unit testing may reduce uncertainty in the units themselves and can be used in a bottom-up testing style approach. By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier.An elaborate hierarchy of unit tests does not equal integration testing. Integration with peripheral units should be included in integration tests, but not in unit tests.Integration testing typically still relies heavily on humans testing manually; high-level or global-scope testing can be difficult to automate, such that manual testing often appears faster and cheaper
  • #35: Unit testing provides a sort of living documentation of the system. Developers looking to learn what functionality is provided by a unit and how to use it can look at the unit tests to gain a basic understanding of the unit's API.Unit test cases embody characteristics that are critical to the success of the unit. These characteristics can indicate appropriate/inappropriate use of a unit as well as negative behaviors that are to be trapped by the unit. A unit test case, in and of itself, documents these critical characteristics, although many software development environments do not rely solely upon code to document the product in development.By contrast, ordinary narrative documentation is more susceptible to drifting from the implementation of the program and will thus become outdated (e.g., design changes, feature creep, relaxed practices in keeping documents up-to-date).
  • #36: A few obvious costs spring to mind:The time spent actually writing unit tests in the first placeNeed to define a suite of testsNeed to find out what to test/when to testNeed to configure a test environment / test configurationSearch for seed dataSearch for configuration files
  • #37: Myth: the idea that unit testing inevitably lowers the cost of application development rests on the reasonable assumption that fixing a bug as soon as possible saves money. Graphs such as the one below typically compare two application’s costs to support this claim. Each solid black line represents an application’s total cost over time.
  • #38: Real reason: They do not factor in the financial repercussions of a delay in the delivery of today’s enterprise applications.An organization’s profitability - the cost associated with the consequences of writing tests.Time expended coding unit tests keeps other features un-built and idling on backlog. The process of implementing unit tests cannot be readily scaled up to prevent backlog because, for most organizations, there are only one or two folks possessing the domain knowledge to add new or enhanced features to a specific application. When these developers code unit tests they are not coding new stuff.
  • #39: A few obvious costs spring to mind:- The time spent actually writing unit tests in the first place- The time spent fixing and updating unit tests, either because you’ve deliberately refactored interfaces between code units or the responsibilities distributed among them, or because tests broke unexpectedly when you made other changes- The tendency – either by you or your colleagues – to avoid improving and refactoring application code out of fear that it may break a load of unit tests and hence incur extra work
  • #40: A few obvious costs spring to mind:The time spent actually writing unit tests in the first placeNeed to define a suite of testsNeed to find out what to test/when to testNeed to configure a test environment / test configurationSearch for seed dataSearch for configuration files
  • #41: - The time spent fixing and updating unit tests, either because you’ve deliberately refactored interfaces between code units or the responsibilities distributed among them, or because tests broke unexpectedly when you made other changesREFACTORING!Fixing broken unit tests!
  • #42: - The tendency – either by you or your colleagues – to avoid improving and refactoring application code out of fear that it may break a load of unit tests and hence incur extra work
  • #43: It makes you think before you write code.Guilty! Make all kind of assumptions -> start to code -> find problems -> avoid or ask questions -> lots of emails/skype/meetings -> deliver something that’s not very clearly documented!
  • #44: It makes you think before you write code.So repeat after me: TDD is Thinking-driven development.
  • #45: It makes you think before you write code.Sure, all the benefits are there: structured incremental progress, good coverage, and confidence when refactoring.But over and over again, when I see people starting to think about their first test, it comes back to me: It’s the think-before-you-act thing.In a user session from a Israel developers group (Israeli Software Craftsmanship User Group), we did the kata for counting code lines (3 times with 3 different groups). And three times, almost at the beginning, questions came up: -What constitutes a line? - In what language are we writing? - Do we count blank lines? - Does an “if” block counts as one line, even if it spreads over four lines? - Does a line need to contain compiling code?And so on. All of these questions came up before the first test (empty string, zero lines) or immediately after it. This kind of thinking and discussion before writing the code is what makes quality code.So repeat after me: TDD is Thinking-driven development.
  • #47: Doesn’t have to be too complex to setup and configure (you have to just set it and forget it).Some early Microsoft test systems took almost a day to prepare (install all tools, all modules, prepare and configure everything).Developers didn’t really want to use them.
  • #48: Difficult to obtain in a database environment. DBs are big.Possible solutions:Test configuration in Visual Studio projects -> different destination databaseSmall set of data (not 100 GBs of a db for testing functionality);Specific seed data for important tables (maybe few MB);This leads us to the next 2 questions: what to test and what NOT to test?
  • #49: 1.A well written unit test works very well as such - it demonstrates how to run a module and shows the expected results;2. They need performance tuning more often, and when tuning we may have to completely rewrite a slow query, improving its performance while keeping its functionality intact.
  • #50: 1. And when we fix those bugs, we need to make sure that we haven't introduce other ones;2. Because usually any unit tests involving the database run much slower than unit testing C++ or C# code alone, we typically do not add as many unit tests as we wish - we must keep the overall time the test harness runs low, within acceptable limits. So keeping unit tests for trivial modules may be very counterproductive as our systems grows, as we get more and more unit tests, and as we begin to wait too much until all our tests complete.
  • #51: If our code refers a non-existing table or database, the database engine will throw a clear to understand error message. If this error message does not get stored in the error log, we should improve error handling. To verify that the DDL in our version control is in sync with the real thing, we can use tools such as SQL Compare.However, explicitly testing database modifications is rarely feasible: typically testing database modifications runs too slow, and the tests are quite delicate - we usually need to maintain them if the database schema changes. Suppose, for example, that we have added one more column to a table. If our select stored procedure does not use this new column, all existing unit tests invoking it can run as is. Unit tests verifying modifications of this table, however, usually need to change -  they need to either ignore this new column, or to include this new column in their expected results.
  • #59: Reward the most talkative persons with:2 RedGate books2 packs of poker cards for Scrum estimationCDs of fine music from our sponsors
  • #60: Ask them to review the speech, the content!