One spec depends on another spec

40 views
Skip to first unread message

Diego Medina

unread,
Jul 17, 2011, 10:31:36 PM7/17/11
to specs2...@googlegroups.com
Hi,

As I continue to write more Selenium tests using specs2, I find that
one spec depends on another spec to do it's job. While you may argue
that specs should all be independent, I am exploring the idea that for
full system test (as in selenium tests), it is ok to have them depend
on each other,

So I have

createCategoriesSpec

which should run before

createOptionsSpec

and in the 3rd place it should run

createItemSpec

I think that all I need is to setup a suite, and call them in order,
but I didn';t find anything about this on the user guide (maybe I
didn't use the right keywords) And if it makes any difference, I run
my tests using sbt by simply call

$ sbt test

Thanks

Diego


--
Diego Medina
Web Developer
(305) 788-4954
di...@fmpwizard.com
http://www.fmpwizard.com

etorreborre

unread,
Jul 18, 2011, 1:39:28 AM7/18/11
to specs2...@googlegroups.com
Hi Diego,

You can create a "parent" specification which "includes" the other specifications:

http://etorreborre.github.com/specs2/guide/org.specs2.guide.SpecStructure.html#Include+or+link+specifications

"These are the selenium specifications"         ^
  include
(childSpec1, childSpec2, childSpec3)

Then, if you add both "sequential" and "stopOnFail" arguments, they are going to be executed in the order of declaration and the next spec won't be executed unless the previous one passes:

http://etorreborre.github.com/specs2/guide/org.specs2.guide.Runners.html#In+a+Specification

sequential ^ stopOnFail ^

"These are the selenium specifications"
        ^
  include
(childSpec1, childSpec2, childSpec3)
Now, in order to run this with sbt you need to use name conventions where the child specifications are not executed and only the composite one is. With sbt 0.10, this is adding this kind of expression to your build.sbt file:

testOptions := Seq(Tests.Filter(s =>
  Seq("Spec", "Selenium").exists(s.endsWith(_)) &&
    ! s.endsWith("ChildSpec"))

In sbt 0.7.4 you need to override the includeTest method:

  override def includeTest(s: String) = Seq(Tests.Filter(s =>
  Seq("Spec", "Selenium").exists(s.endsWith(_)) &&
    ! s.endsWith("ChildSpec"))

Eric.


Reply all
Reply to author
Forward
0 new messages