Failing test due to Logging

Topics: Exception Handling Application Block, Logging Application Block
Feb 28, 2007 at 9:38 PM
Hi

Hoping someone can help me out. I've got a Unit test that tests that a certain exception is thrown if an argument is not present. As part of the exeception handling for the method I log the exception using Ent Lib. Now locally my test passes fine. However when using TFS Build to run my test I get the test failing with the following

Test method Foo.TestCheckForNullComment threw exception System.Configuration.ConfigurationErrorsException, but exception System.ArgumentNullException was expected. Exception message: System.Configuration.ConfigurationErrorsException: The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c0a77a2b6121c5f7 from configuration could not be created. (c:\Build\Foo\Daily Build\TestResults\svc-sjvtfsservice2UA6241M4J 2007-02-28 133157Mixed Platforms_Debug\Out\Foo.Tests.DLL.config line 32) Should throw a ArgumentNullException when no comment object is set

Anyone able to help me out.

Thanks.
Mar 2, 2007 at 2:15 PM
It sounds like the Logging Application Block may not be able to find its configuration information or the configuration information is incorrect. You may need to add the logging configuration to the configuration file used by TFS during the build testing process. A lot of times they use a separate configuration file other than the configuration file used by the application.

If you are using SystemConfigurationSource as your source for configuration information, you can check to see if the logging settings exist by adding a test for it. Here is an example using NUnit:

[Test]
public void LoggingSettingsExistTest()
{
  IConfigurationSource source = new SystemConfigurationSource();
  LoggingSettings settings = LoggingSettings.GetLoggingSettings(source);
  Assert.IsNotNull(settings);
}

Regards,

Dave

_________________________

David Hayden
Microsost MVP C#
Mar 6, 2007 at 4:06 PM
Hi David

Thanks for replying. I've dropped that test in and it is actually passing when I run it on my build server so I presume the config info is being found correctly. Any other ideas? I'm somewhat stumped!