Incorrect Failure message in SureFire pllugin

7 views
Skip to first unread message

Robert Kilar

unread,
Sep 7, 2011, 10:35:40 AM9/7/11
to specs-users
Hi,

I have a problem with a surefire reports. Long story short:
[code]
class HeadTest extends ScalatraSpecificationWithJunit {

"HEAD" should {
"THIS IS MESSAGE NUMBER 1" >> { true must beTrue }
"THIS IS MESSAGE NUMBER 2" >> { false mustEqual 2 }
}

} [/code]

The section of a report file with FAILED test looks like this:
[code]
<testcase time="0.01" classname="directory/..something/HeadTest"
name="THIS IS MESSAGE NUMBER 2">
<failure message="
Expected: &quot;2&quot;
got: &quot;false&quot;
expected:&lt;[false]&gt; but was:&lt;[2]&gt; expected:&lt;[2]&gt; but
was:&lt;[false]&gt;"
type="org.specs.specification.FailureExceptionWithResult">org.specs.specification.FailureExceptionWithResult:
&apos;false&apos; is not equal to &apos;2&apos;
at NAMEOFTHECLASS$$anonfun$1$$anonfun$apply$5.apply(HeadTest.scala:
25)


REST IS JUST STACK TRACE [/code]

The there is created report on jenkins with Error Message section
taken from
<failure message="
Expected: &quot;2&quot;
got: &quot;false&quot;......


But i would like to have failure message which looks sth like that
<failure message="HEAD THIS IS MESSAGE NUMBER 2">
Is there any way to achieve that?

etorreborre

unread,
Sep 7, 2011, 7:02:08 PM9/7/11
to specs...@googlegroups.com
Hi Robert,

Some expectations are actually hard to interpret when they fail: "request.isAccepted must beTrue" for example.

What you need here is the "aka" operator to add a description to the failing expectation:

  request.isAccepted aka "the service request is accepted" must beTrue

In that case, the failure message will include "the service request is accepted".

Eric.

Robert Kilar

unread,
Sep 8, 2011, 6:10:46 AM9/8/11
to specs-users
Great! This helps me a lot and if the answer for the next question is
no it's probably the only way.

If we have that kind of construction:

"MSG" should{
"MSG1" >> { sth1 mustEqual sth2 }
"MSG2" >> { sth3 mustEqual sth4 }
"MSG3" >> { sth5 mustEqual sth6 }
"MSG4" >> { sth7 mustEqual sth8 }
}

If failure occurs in any of these sections, for example in last one is
there way the message failure will be result of concatenation(putting
togheter) of "MSG" + "MSG4" because if I use aka method I should write
it like this


"MSG" should{
"MSG1" >> { sth1 aka "MSG MSG1" mustEqual sth2 }
"MSG2" >> { sth3 aka "MSG MSG2" mustEqual sth4 }
"MSG3" >> { sth5 aka "MSG MSG3" mustEqual sth6 }
"MSG4" >> { sth7 aka "MSG MSG4" mustEqual sth8 }
}

Thanks again for your help!

Robert

On 8 Wrz, 01:02, etorreborre <etorrebo...@gmail.com> wrote:
> Hi Robert,
>
> Some expectations are actually hard to interpret when they fail:
> "request.isAccepted must beTrue" for example.
>
> What you need here is the "aka" operator<http://code.google.com/p/specs/wiki/MatchersGuide#Precise_failures>to add a description to the failing expectation:

etorreborre

unread,
Sep 8, 2011, 8:42:18 AM9/8/11
to specs...@googlegroups.com
I don't really know about your specific context, but you might be able to do 2 things:
  1. Generate the examples   
  "MSG" should {
    for (i <- 1 to n) {
      "example "+i in {
        sthg(i) aka "MSG"+i must_== other(i)
      }
    }
  }

   2 Use DataTables to group the values in a table and have a function execute each row:


Eric.

Reply all
Reply to author
Forward
0 new messages