Comment 1 for bug 777810

Revision history for this message
Rechenelf (matklaus) wrote :

I have worked on a solution, here it is. Would it be possible to integrate this in NUnit itself?

[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
public class UnderDevelopmentAttribute : PropertyAttribute
{
  public UnderDevelopmentAttribute()
    : base("UnderDevelopment")
  { }
}

[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool IsDebuggerPresent();

public static bool IsDebuggerAttached
{
    get
    {
 return System.Diagnostics.Debugger.IsAttached /* managed */
   || IsDebuggerPresent() /* unmanged */;
    }
}

[SetUp]
public void Setup()
{
    if (TestContext.Properties.Contains("UnderDevelopment"))
    {
 if (!IsDebuggerAttached)
     Assert.Ignore("under development");
    }
}