开发者

Can you recommend me a way to create a sample portion of a data-base as an xml file to be consumed by Unit Tests? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this question

Can you recommend me a way or tell me the most common practice to create a sample portion of a data-base as an xml file so that I can use it from my unit tests without w开发者_如何学Corrying about Db state to be persistent?

Is there any frame work to overcome such a scenerio including the functionality that after each test I can get back to the previous state of the XML file which will be the sample data obtained from the Db?

Thanks


Look at the NDbUnit framework. It's designed for exactly that test setup - having a database filled by data from an XML file.

Tip:
Use it in combination with an in-memory database system such as System.Data.SQLite and you get rid of the necessity to hit a server machine, thus making your database-involving tests (which aren't - strictly speaking - unit tests, but integration tests) more reliable and lightning-fast.

HTH!
Thomas


If your test hits either a database or an XML it isn't a Unit Test it is an integration test.

If you are looking to do true unit tests google for the Object Mother pattern.

If you are looking to do integration tests that hit the database you can use Transactions to ensure that database changes are not persisted outside the scope of the test.

I hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜