[
https://issues.apache.org/jira/browse/DELTASPIKE-1151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Craig McIlwee updated DELTASPIKE-1151:
--------------------------------------
Description:
This is a clone of DELTASPIKE-727. Original text:
{quote}
CdiTestRunner logs the "started", "finished" and "failed"-events via
org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner.LogRunListener.
Using CdiTestRunner in more than one test class leads to the repeated logging
of said lines, with one more duplicate per @RunWith(CdiTestRunner) usage.
I've analyzed the problem a bit: CdiTestRunner works by adding an
LogRunListener instance to the RunNotifier in CdiTestRunner#addLogRunListener,
which also keeps track of the RunNotifiers that already have the Listener
attached via the static notifierIdentities Set, only adding the Listener if the
RunNotifier isn't in the Set. The problem is that notifierIdentities gets
cleared in CdiTestRunner.AfterClassStatement#evaluate, which leaves the
Listener alone and thus defeats the purpose of the Set in the first place.
I've tried removing the notifierIdentities.clear() from evaluate which fixes
this issue, but I'm unsure if that's the right fix for the problem. (Writing a
unit test which demonstrates the issue would be easy, but I have no idea how to
provide a test that actually fails based on the test's log output.)
{quote}
I've confirmed that this is fact the case. Will attach a screenshot showing
that the {{LogRunListeners}} accumulate on the same {{RunNotifier}} instance,
and as a result you get duplicated test start and test finish logging for every
log method. This compounds per test class that uses {{CdiTestRunner}}.
On top of that is an issue with log handlers accumulating. {{CdiTestRunner}}
uses a static final {{java.util.Logger}} but every new instance will add an
additional {{ConsoleHandler}}. As a result, each log statement is printed
multiple times.
With these two issues, each class that is run with {{CdiTestRunner}} adds a new
listener and a new handler so for each class you get 2 more additional log
lines than with the previous class that was run.
was:
This is a clone of DELTASPIKE-727. Original text:
{quote}
CdiTestRunner logs the "started", "finished" and "failed"-events via
org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner.LogRunListener.
Using CdiTestRunner in more than one test class leads to the repeated logging
of said lines, with one more duplicate per @RunWith(CdiTestRunner) usage.
I've analyzed the problem a bit: CdiTestRunner works by adding an
LogRunListener instance to the RunNotifier in CdiTestRunner#addLogRunListener,
which also keeps track of the RunNotifiers that already have the Listener
attached via the static notifierIdentities Set, only adding the Listener if the
RunNotifier isn't in the Set. The problem is that notifierIdentities gets
cleared in CdiTestRunner.AfterClassStatement#evaluate, which leaves the
Listener alone and thus defeats the purpose of the Set in the first place.
I've tried removing the notifierIdentities.clear() from evaluate which fixes
this issue, but I'm unsure if that's the right fix for the problem. (Writing a
unit test which demonstrates the issue would be easy, but I have no idea how to
provide a test that actually fails based on the test's log output.)
{quote}
I've confirmed that this is fact the case. Will attach a screenshot showing
that the {{LogRunListeners}} accumulate on the same {{RunNotifier}} instance,
and as a result you get duplicated test start and test finish logging for every
log method. This compounds per test class that uses {{CdiTestRunner}}.
On top of that is an issue with log handlers accumulating. {{CdiTestRunner}}
uses a static final {{java.util.Logger}} but every new instance will add an
additional {{ConsoleHandler}}. As a result, each log statement is printed
multiple times.
As a result of these two issues, each class that is run with {{CdiTestRunner}}
adds a new listener and a new handler so for each class you get 2 more
additional log lines than with the previous class that was run.
> CdiTestSuiteRunner.LogRunListener logs multiple times
> -----------------------------------------------------
>
> Key: DELTASPIKE-1151
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-1151
> Project: DeltaSpike
> Issue Type: Bug
> Components: TestControl
> Affects Versions: 1.3.0, 1.6.1
> Environment: DeltaSpike 1.3.0 and 1.6.1
> JUnit 4 via maven-surefire-plugin
> Reporter: Craig McIlwee
> Priority: Trivial
> Attachments: duplicate_listeners.png
>
>
> This is a clone of DELTASPIKE-727. Original text:
> {quote}
> CdiTestRunner logs the "started", "finished" and "failed"-events via
> org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner.LogRunListener.
> Using CdiTestRunner in more than one test class leads to the repeated
> logging of said lines, with one more duplicate per @RunWith(CdiTestRunner)
> usage.
> I've analyzed the problem a bit: CdiTestRunner works by adding an
> LogRunListener instance to the RunNotifier in
> CdiTestRunner#addLogRunListener, which also keeps track of the RunNotifiers
> that already have the Listener attached via the static notifierIdentities
> Set, only adding the Listener if the RunNotifier isn't in the Set. The
> problem is that notifierIdentities gets cleared in
> CdiTestRunner.AfterClassStatement#evaluate, which leaves the Listener alone
> and thus defeats the purpose of the Set in the first place.
> I've tried removing the notifierIdentities.clear() from evaluate which fixes
> this issue, but I'm unsure if that's the right fix for the problem. (Writing
> a unit test which demonstrates the issue would be easy, but I have no idea
> how to provide a test that actually fails based on the test's log output.)
> {quote}
> I've confirmed that this is fact the case. Will attach a screenshot showing
> that the {{LogRunListeners}} accumulate on the same {{RunNotifier}} instance,
> and as a result you get duplicated test start and test finish logging for
> every log method. This compounds per test class that uses {{CdiTestRunner}}.
> On top of that is an issue with log handlers accumulating. {{CdiTestRunner}}
> uses a static final {{java.util.Logger}} but every new instance will add an
> additional {{ConsoleHandler}}. As a result, each log statement is printed
> multiple times.
> With these two issues, each class that is run with {{CdiTestRunner}} adds a
> new listener and a new handler so for each class you get 2 more additional
> log lines than with the previous class that was run.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)