Why use Parameterized Tests

Some tests run the same assertions on different sets of data. Instead of re-writing the same tests with different sets of data, developers should write one parameterized test.

What are Parameterized tests

Parameterized Tests are test that allows you to pass in a multitude of different set values into a test, instead of having to create the same test for just another set of data. How is this different from [Theories]. [Theories] are the idea of testing a reversible mathematical formula, where it shouldn't matter what the given data is. Unlike Theories, Parameterized Tests have a known expected result and the potential value that should in the end equal the expected.

Parameterized Test Styles

There are two styles of writing parameterized unit tests in FlexUnit, TestNG and JUint style. TestNG style works very well with ad-hoc type test classes that do not share similar data sets between tests. JUnit Style, on the other hand, is best used for test classes that do share similar data sets between tests. For more information see Parameterized Test Styles

Parameterized Test Example

See this code example for an example of a TestNG style parameterized test.

  • No labels