These are chat archives for etorreborre/specs2

28th
Nov 2016
Edmondo Porcu
@edmondo1984
Nov 28 2016 09:33
thanks
@etorreborre amazing
can we use the specfinder for it too?
Eric Torreborre
@etorreborre
Nov 28 2016 10:26
yes, I just took a list of spec to make it shorter here
Edmondo Porcu
@edmondo1984
Nov 28 2016 14:06
we get the X @eir
the problem @etorreborre with that code is that it doesn't handle failures
5 examples, 0 failure, 0 error
[info]
[info] Eiric Server+ EiricOpenMarketSpecx EiricServerAdvancesSpecx EiricServerInstallmentsSpecx EiricServerReverseInvoiceBlockSpecx EiricServerReverseInvoicesSpec+ EricEventNotificationSpec
[info]
[info] Total for specification Eiric Server
[info] Finished in 18 seconds, 659 ms
[info] 6 specifications, 38 examples, 47 expectations, 24 failures, 0 error, 4 pending
but the parent specification succeeds
Eric Torreborre
@etorreborre
Nov 28 2016 14:22
Here is a variation which will fail the parent specification
import org.specs2.Specification
import org.specs2.main.Arguments
import org.specs2.specification.BeforeAll
import org.specs2.specification.core.{Env, Fragments}
import scalaz._, Scalaz._

class MasterSpec extends Specification with BeforeAll { def is =

  "parent spec".title ^ br ^
    "run all the specifications" ! runAll ^ br ^
    "Results" ^ br ^
    Fragments.foreach(List(new Spec1, new Spec2)) { s =>
      link(s) ^ br
    }

  def beforeAll = "initialize the system".pp

  def runAll = {
    val stats = List(new Spec1, new Spec2).map { s =>
      specs2.run.report(Env(arguments = Arguments("console", "html"))).apply(s).runOption
    }.flatten.foldMap(identity)

    stats.result
  }

}

class Spec1 extends Specification { def is = s2"""
  test1 $ko
"""
}

class Spec2 extends Specification { def is = s2"""
  test2 $ok
"""
}