Unit tests logged (or run) multiple times

Posted by HeavyWave on Stack Overflow See other posts from Stack Overflow or by HeavyWave
Published on 2010-06-15T05:24:22Z Indexed on 2010/06/15 8:02 UTC
Read the original article Hit count: 136

Filed under:
|

I have this simple test:

protected readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().ReflectedType);
private static int count = 0;
[Test]
public void TestConfiguredSuccessfully()
{
    logger.Debug("in test method" + count++);
}

log4net is set up like this:

[TestFixtureSetUp]
public void SetUp()
{
    log4net.Config.BasicConfigurator.Configure();
}

The problem is, that if I run this test in nUnit once, I get the output (as expected):

1742 [TestRunnerThread] DEBUG Tests.TestSomthing (null) - in test method0

But if I press RUN in nUnit.exe again (or more) I get the following:

1742 [TestRunnerThread] DEBUG Tests.TestSomthing (null) - in test method1
1742 [TestRunnerThread] DEBUG Tests.TestSomthing (null) - in test method1

And so on (if I run it 5 times, I'll get 5 repeating lines). Now, if I run the same test alone from reSharper the output is fine and does not repeat. However, if I run this test along side 2 other tests in the same class, the output is repeated three times.

I am totally confused. What the hell is going on here?

© Stack Overflow or respective owner

Related posts about c#

Related posts about nunit