Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm working on a project that writes ADO.NET code for a database. Source code located here: GenTools. It reads the stored procedures and tables from a database and outputs C# code. I added unit testing to the project using NUnit, and hit a stumbling block on testing the generated code.

Right now, I'm following these steps to test the generated code:

  1. Generate code
  2. Compile the generated code into an assembly
  3. Load assembly
  4. Use reflection to test generated code

The problem with this approach is that the tests have to be ran in order. The next step will never succeed if the previous one fails, and none of the steps can be left out. An example is here.

I don't like this setup because once step #4 is reached, a failed test on the generated code will prevent the rest from running.

Is there way way to make sure the first 3 steps run sequentially, then have all tests in step #4 seperated out? I don't mind switching testing frameworks.

share|improve this question
 
Perhaps you are looking to run the first 3 steps in [TestFixtureSetUp] ? –  YK1 Jun 1 at 22:52
 
Have you tried CodeDom? msdn.microsoft.com/en-us/library/y2k85ax6(v=vs.110).aspx –  Michael Hartmann Jun 1 at 23:27
 
I do some testing during steps 1, 2 and 3 (example) that wouldn't make sense inside of TestFixtureSetUp. If I could dictate the order of test fixtures, then that solution would work. –  Chris Cartwright Jun 3 at 3:15
 
CodeDom looks like a way to generate the code, not test it once it has been generated. –  Chris Cartwright Jun 3 at 3:16

1 Answer

The TestNG test framework allows you to establish dependencies such that later tests depend on earlier tests, and you have good control over the details. I have more detail on ordering of tests here:

http://ancient-marinator.blogspot.ca/2013/05/on-testing-scheduling-your-tests.html

Naturally, TestNG has its own web site: http://testng.org/doc/index.html

share|improve this answer
 
I need the framework to be C#; otherwise promising. –  Chris Cartwright Jun 4 at 1:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.