Last active
August 29, 2015 14:04
-
-
Save benbrandt22/da09f6fa858c5370bafc to your computer and use it in GitHub Desktop.
Logging to MSTest Unit Test Output with Common.Logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<configSections> | |
<sectionGroup name="common"> | |
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> | |
</sectionGroup> | |
</configSections> | |
<common> | |
<logging> | |
<factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging"> | |
<arg key="level" value="TRACE" /> | |
<arg key="showLogName" value="true" /> | |
<arg key="showDataTime" value="true" /> | |
<arg key="dateTimeFormat" value="HH:mm:ss.fff" /> | |
</factoryAdapter> | |
</logging> | |
</common> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int AddIntegers(int a, int b) | |
{ | |
var log = LogManager.GetLogger("LoggingTo.UnitTestOutput.Demo"); | |
log.DebugFormat("Adding integers {0} and {1}...", a, b); | |
int result = (a + b); | |
log.DebugFormat("Sum = {0}", result); | |
return result; | |
} | |
[TestMethod] | |
public void AddIntegersTest() { | |
int expected = 22; | |
int actual = AddIntegers(10, 12); | |
Assert.AreEqual(expected, actual); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment