V3 Documentation

NCrunch.Framework.RequiresCapability Attribute

NCrunch.Framework Attribute


This attribute is used to declare that a test can only be run on a machine configured to support the specified capability. It is only useful when using NCrunch's distributed processing features.

This attribute can be specified at test, fixture, or assembly level. When specified at assembly level, it will automatically apply to all tests within the assembly.

Declaration In NCrunch.Framework.dll

namespace NCrunch.Framework
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Assembly, AllowMultiple = true)]
    public class RequiresCapabilityAttribute: Attribute
        public RequiresCapabilityAttribute(string capabilityName)
            CapabilityName = capabilityName;

        public string CapabilityName { get; private set; }

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

[NCrunch.Framework.RequiresCapability("Windows 8")]
[NCrunch.Framework.RequiresCapability("Local database")]
public void MyTest()


Capabilities provide a convenient way of controlling which tests can be executed on a particular client or grid node. Note that you can also apply similar controls using the tests to execute on this machine configuration setting.

This attribute can only be used to control the execution of tests. To control the building of projects, you should instead use the Required Capabilities configuration setting.