Re: Am I Running Under NUnit?

"Charlie Poole" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <00f701c89e63$e7b02210$6401a8c0@ferrari>
Hi Ron,
 
The code is wrong on several levels:
 
1) Tactically, because it will fail if your test references a different
version of the framework than the one it
was built against.
 
2) Strategically, because the presense of a Test attribute doesn't have to
mean your test is running under
NUnit. However, it may be so for a particular user who never calls the tests
any other way.
 
There are two simple ways to test whether you are running under NUnit... 
 
One is to look at the friendly name of the current appdomain, which is
"domain-<project>" where <project> 
is the name of the assembly or project being executed. Obviously, this is
subject to name clashes.
 
The other - and more accurate - is to search the stack for the name of the
nunit.core assembly.
 
Charlie


  _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Ron Gross
Sent: Monday, April 14, 2008 7:50 AM
To: [email protected]
Subject: [Nunit-users] Am I Running Under NUnit?


How can I implement a function AmIRunningUnderNUnit() ?
I have a logger, and I want to Log only if I'm running under NUnit.

This is a suggested solution:
http://geekswithblogs.net/ajohns/archive/2004/08/05/9389.aspx

But it doesn't work if the test spawns different threads and the function is
called from there.

Thanks,
Ron

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.