how to tell in code if we are running from a testmethod .net test

Posted by fearofawhackplanet on Stack Overflow See other posts from Stack Overflow or by fearofawhackplanet
Published on 2010-03-15T11:33:58Z Indexed on 2010/03/15 11:39 UTC
Read the original article Hit count: 214

Filed under:
|
|

Is there a way to know when code is being called from running a test method?

bool MyMethod()
{
    if ( /* are we running a test? */ )
    {
        return true; // otherwise this will fail from the automated build script
    }
    else
    {
        // run the proper code
    } 
}

and please spare me the "this is a really bad idea" comments :)

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#