Last example not shown in the test report

11 views
Skip to first unread message

Heiko Seeberger

unread,
Jul 14, 2011, 6:27:49 AM7/14/11
to specs2...@googlegroups.com
Hi,

I recently switched from 1.4 to 1.5. Since then the description of the last example will no longer be shown in the test report. In the below snippet the third last line should be:
[info] + should return the correct connections

But it is:
[info] Calling JourneyPlanner.connections
[info] + with a null from should throw an IAE
[info] + with a null to should throw an IAE
[info] + with a null departureTime should throw an IAE
[info] + with equal from and to should throw an IAE
[info] + should return no connections for unknown from or to
[info] + should return no connections for a too late departureTime
[info] + 
[info]  
[info] Total for specification JourneyPlannerSpec

Here is the relevant snippet of the specification:

  "Calling JourneyPlanner.connections" ^

    `with a null from should throw an IAE` ^

    `with a null to should throw an IAE` ^

    `with a null departureTime should throw an IAE` ^

    `with equal from and to should throw an IAE` ^

    `should return no connections for unknown from or to` ^

    `should return no connections for a too late departureTime` ^

    `should return the correct connections`



Adding an "end" helps:

    ...

    `should return the correct connections` ^

  end


Any ideas?

Heiko

--

Heiko Seeberger
Twitter: hseeberger
Blog: heikoseeberger.name
Company: Typesafe - Enterprise-Grade Scala from the Experts
Author of Durchstarten mit Scala, a German tutorial-style Scala book


etorreborre

unread,
Jul 14, 2011, 8:27:31 AM7/14/11
to specs2...@googlegroups.com
That's a regression indeed because I tried to improve the "Auto-Examples" in 1.5 to allow them to span several lines.

I'll fix that tomorrow (I tried something tonight but that didn't work :-( )

Thanks for reporting this,

Eric.

Heiko Seeberger

unread,
Jul 14, 2011, 2:00:44 PM7/14/11
to specs2...@googlegroups.com
On 14 July 2011 14:27, etorreborre <etorr...@gmail.com> wrote:
That's a regression indeed because I tried to improve the "Auto-Examples" in 1.5 to allow them to span several lines.

Phew, I thought I did something wrong ;-)
 
I'll fix that tomorrow (I tried something tonight but that didn't work :-( )

No need to hurry!
 
Thanks for reporting this,

Sure!

Heiko

etorreborre

unread,
Jul 14, 2011, 7:41:20 PM7/14/11
to specs2...@googlegroups.com
Hi Heiko, 

My fix from last night was indeed working but I was not testing it properly :-).

Could you please check that it's working for you (I have a slight doubt)?

Thanks,

Eric.

Heiko Seeberger

unread,
Jul 15, 2011, 2:21:04 AM7/15/11
to specs2...@googlegroups.com
Hi Eric,

I tried 1.6-SNAPSHOT and I get several results, depending on the structure of the source code. Warning: Issues only occur when the source code is "long".

class IssueSpec extends Specification { def is =

  "A text fragment" ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
  p^
  `an example fragment`

  def `an example fragment` = 1 must_== 1
}

=> 

[info] A text fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info]  
[info] + 

Now deleting four "rows":

class IssueSpec extends Specification { def is =

  "A text fragment" ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
    `an example fragment` ^
  p^
  `an example fragment`

  def `an example fragment` = 1 must_== 1
}

=> 

[info] A text fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info] + an example fragment
[info]  
[info] + `an example fragment`
[info] 
[info]   def `an example fragment` = 1 must_== 1
[info] }

Ain't that funny?

Heiko

etorreborre

unread,
Jul 15, 2011, 3:07:00 AM7/15/11
to specs2...@googlegroups.com
Intriguing indeed. I'm relieved to see that adding an "end" fixes the issue, but I'll see what I can do about that.

etorreborre

unread,
Jul 15, 2011, 9:17:21 PM7/15/11
to specs2...@googlegroups.com
Ok, this issue is now fixed in the latest snapshot.

Note however that if the last example spans several lines, only the first line will be reported when there's no end fragment:

"lots of examples" ^
 `example` ^
 `example` ^
 `example` ^
 `example` ^
 { "last one with lots of lines"
   success
 }

That's because there's no way to really know where the example ends by just looking at stacktraces.

Eric.

Heiko Seeberger

unread,
Jul 16, 2011, 8:31:55 AM7/16/11
to specs2...@googlegroups.com
Great, thanks.

Would you recommend to always use an end fragment? If so, you probably should update the documentation :-(

Heiko

etorreborre

unread,
Jul 16, 2011, 7:33:22 PM7/16/11
to specs2...@googlegroups.com
In the documentation on Auto-examples I recommend to use an 'end' for multi-line examples.

More generally though I would also recommend to use an end just because it's more copy and paste friendly. When you have

"this is a brand new system" ^
  "it should do x"           ! x^ 
  "it should do y"           ! y^
                                                          end

Then it's easier to copy a line like "it should do y" and insert it just before the end.

Eric.
Reply all
Reply to author
Forward
0 new messages