serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

StepEventBus.testFinished() method is called twice #135

Open andy-suruceanu opened 6 years ago

andy-suruceanu commented 6 years ago

Hi,

Background: I've played around of registering a custom listener and noticed that the testFinished() method is called twice. I got simple example, the same example used into the tests of serenity-cucumber (e.g. features/samples/calculator/basic_arithmetic.feature)

Troubleshooting: I got digging a bit to find out why it is called twice, and find it's called in 2 places when a scenario is executing

  1. SerenityReporter.handleTestCaseFinished(TestCaseFinished event):240
  2. SerenityBackend.disposeWorld():41

Side effect: So far I've noticed that the side effect is that for the end users which are using custom listener to observe test outcome can have surprises due to that the same test outcome would be received twice. Another side effect is that this fancy Serenity log which all of us love have duplicate entries (see here). I can obviously understand why it's called in SerenityReporter.handleTestCaseFinished, but why it's required in SerenityBackend.disposeWorld()?

Please give a piece of advice!

Versions: Serenity-core-1.9.3 Serenity-cucumber-1.9.3

andy-suruceanu commented 6 years ago

@wakaleo, May I have please a comment about this issue ? Thank you in advance.