Documentation

Documentation
V5 Documentation

NCrunch.Framework.TimeoutAttribute

NCrunch.Framework Attribute

Purpose

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

[NCrunch.Framework.Timeout(5000)]
[Test]
public void MyTest()
{
	...

Recommendations

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