Status of testListeners in 0.13

82 views
Skip to first unread message

Andrew Richards

unread,
Aug 8, 2013, 1:18:55 PM8/8/13
to simple-b...@googlegroups.com
Hi,

In 0.13 if you make a test listener,

testListeners += new MyTestListener

it wants an sbt.TestsListener which receives a sbt.TestEvent. In this the detail Seq contains a list of sbt.testing.Event. From this It's not obvious how to get the name of the test or the test error string (there is a throwable).

Am I missing something?

Andrew

Jeff Olson

unread,
Aug 9, 2013, 11:12:25 AM8/9/13
to simple-b...@googlegroups.com
I'm not the best person to answer your question since I'm curious myself as to what the official answer is, but this is what I found through trial and error. Apparently, each detail item in sbt.TestEvent need not correspond to a specific test case and therefore there is not always a name. What you can do is look at the selector method. There are five different types of Selectors:

SuiteSelector
TestSelector
NestedSuiteSelector
NestedTestSelector
TestWildcardSelector

Of these, the TestSelector and NestedTestSelector have testName methods. In my project all the detail items happen to be TestSelectors and so I can get away with an

  val testName = event.selector.asInstanceOf[TestSelector].testName

Your mileage may vary. As far as the error string goes, I think the only thing available is the message on the throwable.

-Jeff

Andrew Richards

unread,
Aug 12, 2013, 10:11:30 AM8/12/13
to simple-b...@googlegroups.com
Ah great thanks. I hand't delved into the selector. That worked. It looks like any errors are passed in as the throwable so I now have all the information I need. Cheers.
Reply all
Reply to author
Forward
0 new messages