Not Your Mommas Unit Tests - Parameterized Unit Tests

800 views

Published on

Short presentation/fast abstract for Ph.D. seminar on TDD. Source code here: https://gist.github.com/919133

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
800
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
2
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Not Your Mommas Unit Tests - Parameterized Unit Tests

  1. 1. Not your Momma’s unit tests Parameterized Unit Tests<br />SWE-795, Test Driven Development, GMU Spring 2011 – Bill Shelton<br />
  2. 2. What are Parameterized Unit Tests?<br />A unit test that accepts parameters<br />Decouples test data from test logic<br />Facilitates refactoring of test code<br />Allows for exploration using input space partitioning<br />Can express tests as universally quantifiable theories; e.g., ∀ n ∈ N, n > 0: P(n) ⇒ true<br />Sometimes referred to as data-driven testing<br />Aka PUTs<br />
  3. 3.
  4. 4. Unit Test Tool Support<br />Java: JUnit and TestNG<br />TestNG was first, using @Dataprovider<br /> .NET: Pex<br />
  5. 5. What do PUTs look like?<br />
  6. 6. What do PUTs look like?<br />“There’s not a chin behind this beard -- only a fist full of parameterized unit tests.”<br />
  7. 7. <code/><br />
  8. 8. JUnit Theories<br />PUTs on steroids<br />“Theories hold over infinite data sets … JUnit executes theories over a finite set of data points…”<br />Unlike a PUT, a theory must hold true for all values (universally quantifiable)<br />
  9. 9. <code/><br />
  10. 10. Summary<br />PUTs decouple data from test logic<br />Theories are PUTs that must hold true for all inputs<br />

×