Hello,
I have a question on how one of the latest additions to NCrunch works regarding the XUnit v2 fixtures.
I am trying out the Atomic for running acceptance tests, that have fixtures with really long setup times because a lot of data is being loaded into memory. When I am running it with R# test runner, the fixture is being reused in between the test runs and as a result the tests run in a reasonable amount of time, once the setup is done.
However, I noticed, that this is not the case for NCrunch. My only explanation is that it is recreating the fixture every time it is running a single test from those classes that have acceptance tests. I have marked the acceptance test classes with the atomic attribute, but have not seen any change. Should I mark the fixture as atomic instead? The fixture itself is thread safe.
All the best,
Ignas
Remco NCrunch Developer
#10820
24 Jul 2017 13:21 UTC
Hi Ignas,
The Atomic attribute only works when applied at fixture or assembly level. I'm not sure how your acceptance tests are structured, but the attribute usually should be placed on the same class containing the methods that use the Xunit attributes (like Fact).
My understanding of the design of Xunit is that it will usually create a new fixture instance for each call to every method on the fixture. So if you have a fixture containing three 'Fact' methods, then the fixture constructor will be called 3 times, once for each Fact. This should be the same behaviour as under Resharper, since both NCrunch and Resharper invoke Xunit for this handling and Xunit encapsulates this behaviour completely.
A way you can check whether AtomicAttribute is being detected by NCrunch is to turn on the 'Is Atomic' column in the Tests Window and check whether the tests you've marked up are considered to be atomic.
The Atomic attribute only works when applied at fixture or assembly level. I'm not sure how your acceptance tests are structured, but the attribute usually should be placed on the same class containing the methods that use the Xunit attributes (like Fact).
My understanding of the design of Xunit is that it will usually create a new fixture instance for each call to every method on the fixture. So if you have a fixture containing three 'Fact' methods, then the fixture constructor will be called 3 times, once for each Fact. This should be the same behaviour as under Resharper, since both NCrunch and Resharper invoke Xunit for this handling and Xunit encapsulates this behaviour completely.
A way you can check whether AtomicAttribute is being detected by NCrunch is to turn on the 'Is Atomic' column in the Tests Window and check whether the tests you've marked up are considered to be atomic.
Post a reply
Log in to reply.