V5 Documentation


NCrunch.Framework Attribute


This attribute allows you to specify a period (in milliseconds) after which a test or test fixture will time out and be aborted by NCrunch.

Most test frameworks also make use of their own timeout attributes. This attribute is provided for test frameworks that do not have a timeout attribute of their own.

This attribute can be applied at method (test) and type (fixture) level.

Declaration In NCrunch.Framework.dll

namespace NCrunch.Framework
    public class TimeoutAttribute: System.Attribute
        private IDictionary _properties;

        public TimeoutAttribute(int timeout)
            _properties = new Hashtable();
            _properties["Timeout"] = timeout;

        public IDictionary Properties
            get { return _properties; }

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

public void MyTest()


Where possible, you should use the timeout attributes provided by the testing framework you are using. Other test runners will not observe the NCrunch timeout attribute, so this attribute should only be used as a last resort.

Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download