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