xUnit Theory, the Data Driven Unit Test

added by tdupont
4/14/2012 2:01:45 PM

0 Kicks, 182 Views

A good set of unit tests often end up reusing the same code with varied inputs. Rather than copy and paste that test code over and over, we can use the pattern of data driven unit tests to help streamline our test fixtures. This is the practice of having a single test definition be invoked and count as multiple tests at run time. This also enables us to do other dynamic things, such as configuring our unit tests from external sources. :) I love NUnit, but it does not offer data driven unit tests. I frequently use MSTest, but it's data driven tests inconveniently require you to define a DataSource. Meanwhile xUnit offers several lightweight and simple options for defining data driven tests, which it refers to as theories.