开发者

Where to put Automapper maps in Nunit test assembly

开发者 https://www.devze.com 2023-04-02 02:44 出处:网络
I am using Automapper in my application and I am testing the maps with fake objects, so I have slightly different maps in my tests than in my production code, what is the best way to c开发者_Go百科rea

I am using Automapper in my application and I am testing the maps with fake objects, so I have slightly different maps in my tests than in my production code, what is the best way to c开发者_Go百科reate/call the maps, I have the maps sitting right now at each fixture's

[TestFixtureSetUp]

As the Mapper class is static is it possible to read the maps once per "all test" run, because I found it slows down the tests very much

Thank you.


With NUnit you could use [SetUpFixture]:

This is the attribute that marks a class that contains the one-time setup or teardown methods for all the test fixtures under a given namespace. The class may contain at most one method marked with the SetUpAttribute and one method marked with the TearDownAttribute.

With MbUnit you could use [AssemblyFixture] which is executed once per unit test assembly.

0

精彩评论

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