Parameterizing tests with a DataProvider
If we are testing our code using a range of test data, then sometimes, there is little difference between each test apart from the values. Rather than duplicating our Arrange/Act/Assert statements, we can reuse a single method, and the Unity Test Runner will loop through a collection of test data, running the test method for each set of test data. The special method that provides multiple sets of test data to a test method is known as a DataProvider, and we’ll create one in this recipe:
Figure 19.11: Running the test method with many sets of values with a DataProvider method
How to do it...
To parameterize tests with a DataProvider method, follow these steps:
- Create a new 3D Unity project.
- Display the Test Runner panel by going to Window | General | Test Runner.
- Ensure that the EditMode button is selected in the Test Runner panel.
- In the Test Runner panel, click the Create EditMode Test Assembly...