|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
log4j unit test failure + sonarI have a unit test which verifies that certain messages are printed to the logger. Does sonar have some logic which changes the behaviour of the logger?
For more detail here is the code: // setup unit test String caller = "test caller"; String cdiMessage = "test log message"; String logMessage = "- CDI api log - Caller: "+caller+" - Message: "+cdiMessage+Layout.LINE_SEP; StringWriter writer = new StringWriter(); SimpleLayout layout = new SimpleLayout(); BasicConfigurator.configure(new WriterAppender(layout, writer)); org.apache.log4j.LogManager.getLoggerRepository().setThreshold(org.apache.log4j.Level.INFO); // write message to log mClient.onMsgLog(new CDIMsgLogInfo(caller, infoLevel, cdiMessage)); // verify message was written assertEquals("INFO "+logMessage, writer.toString()); And the error is: org.junit.ComparisonFailure: expected:<[INFO - CDI api log - Caller: test caller - Message: test log message ]> but was:<[]> However when run without sonar the test passes. |
|
|
Re: log4j unit test failure + sonarHi Harsha,
What happens when you're launching "mvn test" ? I guess the same unexpected behavior happens as there might be a conflict between the Maven logger configuration and your application logger configuration ? Regards, Freddy On Wed, Oct 21, 2009 at 7:10 PM, harshavsn <harsha.sri-narayana@...> wrote:
|
|
|
Re: log4j unit test failure + sonarHi Freddy,
"mvn test" works as does "mvn install" However I can see the test log messages in the maven log output when I run these commands so it is writing to the main logger. regards, Harsha
|
|
|
Re: log4j unit test failure + sonarShould I file a bug report on this?
Is there a way to ignore a single test in sonar? regards Harsha |
|
|
Re: log4j unit test failure + sonarHi Harsha,
Should I file a bug report on this? Yes please. I'm afraid that there's a conflict with SLF4J/logback used by the Sonar maven plugin.
No. The only workaround is to deactivate execution of unit tests and to reuse XML reports generated by the install phase : mvn sonar:sonar -Dsonar.dynamicAnalysis=reuseReports See also sonar.surefire.reportsPath and sonar.cobertura.reportPath if you don't use standard paths. Regards, Simon |
| Free embeddable forum powered by Nabble | Forum Help |