I'm trying to upgrade to xUnit 2 beta (mostly because of better test discovery) but stumbled over IUseFixture<>
:
public abstract class TestCaseBase : IUseFixture<SelfHostFixture>
{ /*common stuff here*/ }
public class Controller1Test : TestCaseBase {}
public class Controller2Test : TestCaseBase {}
I found that new IClassFixture<>
was almost what I needed except the fixture was created/disposed for every descendant classes (Controller1Test
, Controller2Test
) instead of just once. Well, I could move IClassFixture<SelfHostFixture>
declaration to every test class from the base but why would I setup/dispose my server multiple times? ICollectionFixture<>
didn't worked for me (the fixture's ctor was never fired).
Basically, what I want is:
ICollectionFixture<>
won't work at all because tests within same collection cannot be run in parallel, right?)What am I missing?
Answer: use ICollectionFixture
See http://xunit.github.io/docs/shared-context.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With