Problem with shared contexts

6 views
Skip to first unread message

Jeppe Nejsum Madsen

unread,
Apr 6, 2011, 9:56:21 AM4/6/11
to specs...@googlegroups.com
Hi

Using 1.6.8-SNAPSHOT I see a problem using shared contexts (I'm pretty
sure this used to work, but if somehow I'm not doing it correct,
please advise :-)

I have this:

object ExcelParserSpec extends Specification with Mockito with
MockMatchers with MockRequest {
var inputFile: String = _
var importer:ExcelParser = _

val excel2003 = beforeContext({println("Before 3");inputFile =
"/import/dna.xls"; importer=new ExcelParser(inputFile,
getClass.getResourceAsStream(inputFile))})
val excel2007 = beforeContext({println("Before 7");inputFile =
"/import/dna-2007.xlsm"; importer=new ExcelParser(inputFile,
getClass.getResourceAsStream(inputFile))})

"An Excel 2003 file" ->-(excel2003) should {
"be readable" in {
importer must notBeNull
println("In test")
}
}

"An Excel 2007 file" ->-(excel2007) should {
behave like "An Excel 2003 file"
}
}

But it seems like the 2007 context is never really used. This is the
output I get:

Before 3
In test
Before 7
Before 3
In test

Any hints?

/Jeppe

etorreborre

unread,
Apr 7, 2011, 8:24:37 PM4/7/11
to specs-users
Does it change if:

- you use a class instead of an object for your specification?
- you use shareVariables()?
- you use a different way of running the tests (in junit, in sbt, in
the console)?
- you use specs2 ;-) ?

Eric.

Jeppe Nejsum Madsen

unread,
Apr 8, 2011, 5:26:36 AM4/8/11
to specs...@googlegroups.com
On Fri, Apr 8, 2011 at 2:24 AM, etorreborre <etorr...@gmail.com> wrote:
> Does it change if:
>
>  - you use a class instead of an object for your specification?

No

>  - you use shareVariables()?

No

>  - you use a different way of running the tests (in junit, in sbt, in
> the console)?

No

>  - you use specs2 ;-) ?

Maybe, haven't tried this yet :-)

/Jeppe

> --
> You received this message because you are subscribed to the Google Groups "specs-users" group.
> To post to this group, send email to specs...@googlegroups.com.
> To unsubscribe from this group, send email to specs-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/specs-users?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages