V3 Documentation
Search

NCrunch.Framework.AtomicAttribute

NCrunch.Framework Attribute Introduced NCrunch v3.10

Purpose

Fixtures marked with this attribute are considered to be atomic by NCrunch, meaning that their child tests cannot be run separately from each other. A test being queued for execution under an atomic fixture will result in the entire fixture being queued with its child tests all executed in the same task/batch.

Declaration In NCrunch.Framework.dll

namespace NCrunch.Framework
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
    public class AtomicAttribute: Attribute
    {
    }
}

You can declare this in your own code if you want NCrunch to use it - or otherwise reference the attribute from NCrunch.Framework.dll.

Usage example

[Atomic]
public class MyFixture
{
    [Test]
    public void MyTest()
    {
        ...
    }
}

Recommendations

This attribute works well on fixtures with a high setup but low test execution time, as NCrunch will then run all the child tests together which is much more time and resource efficient.

This attribute can also be used for tests that are sequence dependent within the scope of their fixture, as frameworks will usually execute tests within a predetermined sequence provided the tests are placed in the same execution task/batch by NCrunch.