etorreborre / specs2

Software Specifications for Scala
http://specs2.org
Other
734 stars 214 forks source link

Question about spec execution events #272

Closed vania-pooh closed 10 years ago

vania-pooh commented 10 years ago

Hi! I'm creating a small library based on Specs2 and have a question about events implementation. So far as I understood there only way to somehow attach to Specs2 events is to use either Notifier or Reporter or Exporter traits. Currently I tried to use Notifier which has methods like specStart, specEnd and so on but faced the following problem - when working with contexts and steps I only have some description text and file name with line number. How can I determine e.g. inside contextStart method implementation which spec this context belongs to? Probably there's another trait or base class to be used which provides more structured information. I'm basically searching for something like: http://doc.scalatest.org/1.7/org/scalatest/Reporter.html or http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html

My initial draft is located here: https://github.com/vania-pooh/allure-specs2

etorreborre commented 10 years ago

Sorry about the late answer, I didn't receive any notification from Github. I'm going to have a look at that today.

etorreborre commented 10 years ago

I was thinking that for this sort of use case you could use an internal mutable stack to keep track of the current context. Would that work for you?

vania-pooh commented 10 years ago

Thank you for the commment. Could you provide references to class \ trait names to look for?

etorreborre commented 10 years ago

Sorry again for the late answer, I am on holidays. Here is what I'm thinking of: https://gist.github.com/etorreborre/b8067a0aed3d15d265d2.

vania-pooh commented 10 years ago

Thank you for this example. Will try to use it.