how to write a thread-safe TestReportListener (with sbt 0.13)

23 views
Skip to first unread message

Jeff Olson

unread,
Aug 7, 2013, 4:16:49 PM8/7/13
to simple-b...@googlegroups.com
When writing a custom TestReportListener one needs to account for the fact that it can be invoked concurrently from multiple threads (unless parallelExecution in Test is false), but it isn't clear how to do this correctly.

My use case involves accumulating test information for each 'group' and then doing something with the accumulated information at the end (e.g. writing a report). But it isn't clear how to map the event provided in testEvent to a group. For reference see https://gist.github.com/jdolson/6177988  (using sbt 0.13)

Questions:
  1. does fullyQualifiedName on sbt.testing.Event always correspond to a unique group?
  2. do all the detail items in a given TestEvent correspond to unique group? if so, it would be nice if TestEvent had the group name attached.
  3. can testEvent be invoked concurrently with different (concurrent) calls getting passed events for the same group (i.e. does my ArrayBuffer need to be an ArrayBlockingQueue?)
  4. is there anything else obviously wrong with my example?
Thanks, Jeff
Reply all
Reply to author
Forward
0 new messages