tags:

views:

60

answers:

1

Hi,

is it possible to nest following specs test code

"ClassX" should {
  "throw an IllegalArgumentException if n < 0" in {
    ClassX(-1) must throwA[IllegalArgumentException]
  }
  "throw an IllegalArgumentException if n > 50" in {
    ClassX(51) must throwA[IllegalArgumentException]
  }
  "throw an IllegalArgumentException if n == 35" in {
    ClassX(35) must throwA[IllegalArgumentException]
  }
}

in another in-Statement like:

"ClassX" should {
  "throw an IllegalArgumentException if" in {
    "n < 0" in {
      ClassX(-1) must throwA[IllegalArgumentException]
    }
    "n > 50" in  {
      ClassX(51) must throwA[IllegalArgumentException]
    }
    "n == 35" in  {
      ClassX(35) must throwA[IllegalArgumentException]
    }
  }
}

Because it is easier to read and write

+2  A: 

Yes. See http://code.google.com/p/specs/wiki/DeclareSpecifications for an overview of all the ways you can structure Specs specifications.

David Winslow
Ok. thank you very much. My code above works very well. I had an other mistake in my code thus the test failed.
Antoras