Best Location for Unit Test Data

We’re creating Unit Tests that read data from test data files. We are considering two options:

  1. Creating the test data file in the project, under Source/Tests/Data. This test data file can then be placed into source control, or
  2. Having the Unit Test create the test data file, saving it into the project’s Saved folder (we are excluding the Saved folder from source control).

We’re leaning towards 2, but we wanted to see what opinions are on this.

I haven’t thought about this much, but I would probably do the following:

  • Test data that serves as input to and is required by the unit test should reside in source control
  • Data output files that are generated by the unit tests while they are running should not reside in source control and be considered transient/temporary

We currently don’t have any unit tests requiring or generating data, I believe, but if I had to implement it, I would probably put the input data into MyProject/TestData (or MyPlugin/TestData), and the output files into MyProject/Saved/TestData.