What is the best way to store the test cases from which your xunit tests are loaded?

This is a design / architecture question, so you don't need to provide technical details.

All day long I can find examples on the internet that show how to run xunit unit test, log test results and how to show if it succeeds or fails, but every example on the internet is hardcoded and no one shows examples of how you store yours. test cases (nunit or junit) efficiently in such a way as to make it possible to build hundreds or thousands of tests and load them into your test engine.

I assume this will be done using an XML file or database table. Can any of you share what you think is the best method for storing tests to be loaded by test code? I need to write a testing framework that will eventually have thousands of tests for a typical web workflow application, and I want to get it right.

Perhaps describe your answer in the context of running unit tests on the Advanced Google Search page, which has many choices as well as hundreds of choices, and so on.

+2


source to share


2 answers


I agree that the important thing here is to keep it simple and let it grow "naturally." Tests are just as important as your other code and need to be refactored just as vigorously.

When it comes to actual unit tests (as opposed to integration tests, where you test the entire stack from UI to database), it's very important that you keep everything you need to run them in your solution so that developers always have the latest stuff. when updating the original files. Also, you should aim for a thrill-free installation scenario where new developers can simply grab the source files from source control and run tests without the need for customization.



The RowTest function is really good for simple scenarios, but if you are dealing with complex scenarios, you should look into the Test Data Builder template, which allows you to define default scenarios and then their variations.

I like to keep my test data as close to the tests as possible, which allows me to really see what's going on in the tests. So I don't think the question is whether to use XML or a database, these are just different formats for representing the data, but do you really want to separate your test data from your tests?

+1


source


If you're getting "data driven tests" you should take a look at the RowTest approach and equivalents. NUnit borrowed this from MBUnit. xUnit seems to have an even more extensible solution to this through Theory and PropertyData , where you don't need to specify the inputs in your code; you can generate inputs from arbitrary function, table or SQL Server database.

I've never had a need for anything on the Rowtest method (which is also rare) .. so can't alert you to any dragons. Alternatively, you could even use Fit / Fitnesse to do this if you can't do the above approaches; although not technically an acceptance test.



As for the "testing framework", maybe YAGNI, maybe so. Start, start small, keep it simple, build a test project over time.

0


source







All Articles