Question

I have a scenario where I'm needing to create tests at runtime based on a script.

I have a set of scenarios defined in a text file that need to be interpreted and each one should be run as an unit test under nunit.

I've created a general IntegrationTestRunner to read the data and run one big test for each scenario that is defined. This works fine.

However, it seems to make good sense that each scenario should be it's own unit test.

Is there a way to dynamically create nunit-based unit tests at runtime using reflection?

Thank you!

Était-ce utile?

La solution

It'd be quicker and far easier to create a class that reads all the test cases from your file and creates TestCaseData objects (see this page). You can set the name of each test case via the Name property on the TestCaseData.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top