A small demo program in C#, demonstrating the dynamic generation of Xunit tests for each filename in a search path, where the filename matches a pattern. This Gist requires xUnit.net to compile.
After reading in the EnumerateFilesFixtureAttribute on the type Tests.AutoPopulatedTest, the main program enumerates all files in the path specified by the attribute that also match the searchPattern (e.g. "*.json").
It then uses System.Reflection.Emit to emit a test method for each of the files found. Each generated test method is also decorated with a [Xunit.FactAttribute] to make the Xunit test runner recognize it.
By modifying the value of the generated DisplayName property, one can change how the generated tests are displayed in the Xunit GUI runner, for example.