最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Add a global [OneTimeSetUp][OneTimeTearDown] for tests spanning multiple projects - Stack Overflow

programmeradmin1浏览0评论

I'm using rider and running integration tests across multiple projects which all run in parallel.

Prior to running my tests, I need to clear down all data in my database. The reason I'm not adding a [TearDown] per test, is because some fixtures work with the same concepts (and would interfere with one another). Also, with so many test classes it seems a lot faster to have just one [TearDown] at the beginning or end of all tests.

[SetUpFixture] of course covers only a namespace, so it will not help this scenario where I need to cover multiple test projects.

Does anyone have any solutions or suggestions to this problem? I could write a command line script of course, but then I'd lose the benefits of Rider's test runner.

I'm using rider and running integration tests across multiple projects which all run in parallel.

Prior to running my tests, I need to clear down all data in my database. The reason I'm not adding a [TearDown] per test, is because some fixtures work with the same concepts (and would interfere with one another). Also, with so many test classes it seems a lot faster to have just one [TearDown] at the beginning or end of all tests.

[SetUpFixture] of course covers only a namespace, so it will not help this scenario where I need to cover multiple test projects.

Does anyone have any solutions or suggestions to this problem? I could write a command line script of course, but then I'd lose the benefits of Rider's test runner.

Share Improve this question asked Mar 6 at 11:02 FBryant87FBryant87 4,6187 gold badges51 silver badges90 bronze badges 3
  • stackoverflow/a/3188421/43846 – stuartd Commented Mar 6 at 15:09
  • [SetUpFixture] runs once per project I believe – FBryant87 Commented Mar 6 at 15:28
  • Ah, yes of course it does, sorry. You could perhaps ‘add file as link’ a setup in all the test projects, though I think you might need a way to make sure it only actually runs once – stuartd Commented Mar 6 at 16:48
Add a comment  | 

1 Answer 1

Reset to default 1

The thing is that the most coarse-grained level of NUnit is an assembly, i.e. it is written with the idea in mind that resources are to be shared within an assembly, but not across several assemblies.

Now it depends on how much you want to work against the framework

发布评论

评论列表(0)

  1. 暂无评论