Search code examples
scalaspecs2

specs2 run a specific test


I'm trying to run a specific test with specs2 and I'm running into one minor issue there. This is the code I'm running:

import org.specs2._

class DemoSpec2 extends Specification {
  def is = s2"""

  This is a specification to check the 'Hello world' string

  The 'Hello world' string should
    contain 11 characters              ${Set11().e1}        ${tag("feature")}
    start with 'Hello'                 ${Set2().e2}         ${tag("abc")}

                                       """

  case class Set11(){ def e1 = 1 must_== 1 }
  case class Set2(){ def e2 = 1 must_== 1 }

}

The ${tag("feature")} part makes an extra line in the output. So it looks like:

[info]   The 'Hello world' string should
[info]     + contain 11 characters
[info]         
[info]     + start with 'Hello'

I don't want the extra line. What I'm doing wrong?


Solution

  • You are not doing anything wrong, this is a reporting bug (fixed in the latest 2.2-SNAPSHOT). In the meantime things should be ok if you suppress spaces:

    import org.specs2._
    
    class DemoSpec2 extends Specification {
      def is = s2"""
    
      This is a specification to check the 'Hello world' string
    
      The 'Hello world' string should
        contain 11 characters              ${Set11().e1}${("feature")}
        start with 'Hello'                 ${Set2().e2}${tag("abc")}
    
                                       """
      case class Set11(){ def e1 = 1 must_== 1 }
      case class Set2(){ def e2 = 1 must_== 1 }
    }