mergify[bot] on master
Update mockito-core to 3.7.7 Merge pull request #891 from sc… (compare)
etorreborre on master
Update sbt-pgp to 2.1.1 (#889) (compare)
etorreborre on master
Update mockito-core to 3.7.0 (#… (compare)
DelayedInit
for mutable specs, but I haven’t had a look yet at the s2
macro. There seems to be a way to do it: https://github.com/lampepfl/dotty/issues/5095#issuecomment-423299541
s2
macro.
ScalaJS is supported but I am not a primary user so it is hard for me to tell. Using a Future
as a result in an example should work thanks to this implicit:
implicit class futureAsResult[T](f: => Future[T])(implicit ee: ExecutionEnv, asResult: AsResult[T]) extends FutureAsResult[T](f)
So if your class has an implicit ExecutionEnv
like class MySpec(implicit ee: ExecutionEnv) extends Specification
you should be able to write ”test ok” >> Future(ok)
Future(ok)
works on scalajs with the global EC.AroundEach
trait for thatclass MySpec extends mutable.Specification with SkipAll {
"this is ok" >> ok
"this is ko" >> ko
}
import org.specs2.specification._
import org.specs2.execute._
trait SkipAll extends AroundEach {
def around[R : AsResult](r: =>R) =
Skipped("skipped")
}
Future[Result]
for the specs and is there a way I could create similar functionality for IO? I'm missing a piece of code somewhere but I'm not sure where it is inside the specs2 repo.
AsExecution
typeclass to integrate IO
:
import org.specs2.execute.{AsResult}
import org.specs2.specification.core.{AsExecution, Execution}
import scala.concurrent._
case class IO[T](run: ExecutionContext => Future[T])
object IO {
def successful[T](t: =>T): IO[T] =
IO(_ => Future.successful(t))
implicit def ioAsExecution[R : AsResult]: AsExecution[IO[R]] = new AsExecution[IO[R]] {
def execute(io: =>IO[R]): Execution =
Execution.withEnvAsync(env => io.run(env.executionContext))
}
}
class TestMutableSpec extends mutable.Specification {
"e1" >> {
IO.successful(ok)
}
}
Hey everyone. I wonder, is it possible to create a one-column Table
with some DSL? I mean the following doesn't work because it cannot differentiate where header ends and actual rows begin:
class MyFancySpec extends mutable.Specification with mutable.Tables {
"should be fine for every valid string value" in {
"Valid String" |
"valid-str-1" |
"valid-str-2" |
"valid-str-3" |> { validStr =>
myTestee(validStr) must beFine
}
}
}
Is it possible to achieve something like this somehow?
Result.foreach
: https://etorreborre.github.io/specs2/guide/SPECS2-4.2.0/org.specs2.guide.ForLoops.html
def testee(foo: Int, bar: Int): String = s"foo$foo,bar$bar"
"simple" >> {
"foo" | "result" |
1 ! "foo1" |
2 ! "foo2" |
3 ! "foo3" |> { (foo, fooRes) =>
"bar" | "result" |
4 ! "bar4" |
5 ! "bar?" |
6 ! "bar6" |> { (bar, barRes) =>
testee(foo, bar) must_=== s"$fooRes,$barRes"
}
}
}
If all cases pass then everything is just fine. But if some combination fails, then result test output provides no useful information at all:
[info] MyTableSpec
[info] x simple (39 ms)
– so it only says that the entire "simple" case fails and nothing more.
While if I do testing for a single level table, it shows much more details.
Hi @diesalbla there’s no great way to do that at the moment, it’s more like a pattern
case class MyResource(value: Int)
object Resource {
var resource: MyResource = null
def getResource: MyResource = {
if (resource == null) {
println("creating resource")
resource = MyResource(1)
resource
} else resource
}
def closeResource() = {
println("closing resource")
resource = null
}
}
class Resource1Spec extends Specification { def is =
s2"""
use a shared resource in spec1 $useIt
"""
def useIt = {
println("execute spec1")
Resource.getResource.value === 1
}
}
class Resource2Spec extends Specification { def is =
s2"""
use a shared resource in spec2 $useIt
"""
def useIt = {
println("execute spec2")
Resource.getResource.value === 1
}
}
class ResourceSpec extends Specification { def is =
s2"""
${link(new Resource1Spec)}
${link(new Resource2Spec)}
${step(Resource.closeResource())}
"""
}
You need to run the ResourceSpec
with the all
command-line argument so that all the linked specifications are also executed
”simple” >> {...}
by eg {…}
in your specification (this creates an “auto-example”, an example without a description, which will always show the resulting data table. Fixing this seems possible but it will take me a bit more time
could not find implicit value for evidence parameter of type org.specs2.specification.core.AsExecution[Object]
examplesBlock
method... but I cannot find it in the source code... Was it removed or replaced?Result.foreach
quite some time ago now: https://etorreborre.github.io/specs2/guide/SPECS2-4.10.0/org.specs2.guide.ForLoops.html#a-list-of-results
Hello!
Following these docs, I've tried to run:
sbt> testOnly -- smartdiffs show,separators,triggerSize,shortenSize,diffRatio,full
But I get
[error] stack trace is suppressed; run last Test / testOnly for the full output
[error] (Test / testOnly) java.lang.IllegalArgumentException: Argument unrecognized by ScalaTest's Runner: smartdiffs
[error] Total time: 2 s, completed 30/dez/2020 11:22:38