NullPointerException when specifying scalaCheckInitialSeed
matthughes opened this issue · 1 comments
matthughes commented
When a scalacheck test fails, it emits an error like:
munit.FailException: Failing seed: w7LhNFbfMx1uonWH2Hvt-N0sxdlm1xkXqMbZtSm3xoA=
You can reproduce this failure by adding the following override to your suite:
override val scalaCheckInitialSeed = "w7LhNFbfMx1uonWH2Hvt-N0sxdlm1xkXqMbZtSm3xoA="
If I add that as specified, I get a NPE:
class ExampleTest extends ScalaCheckEffectSuite {
override val scalaCheckInitialSeed = "w7LhNFbfMx1uonWH2Hvt-N0sxdlm1xkXqMbZtSm3xoA="
test("foo") {
assert(true, true)
}
}
java.lang.NullPointerException: Cannot invoke "String.length()" because "s$2" is null
at org.scalacheck.rng.Seed$.fromBase64$$anonfun$1(Seed.scala:188)
at scala.util.Try$.apply(Try.scala:210)
at org.scalacheck.rng.Seed$.fromBase64(Seed.scala:192)
at munit.ScalaCheckEffectSuite.$init$$$anonfun$1(ScalaCheckEffectSuite.scala:36)
at scala.Option.getOrElse(Option.scala:201)
at munit.ScalaCheckEffectSuite.$init$(ScalaCheckEffectSuite.scala:34)
at ExampleTest.<init>
If I change that val
to a def
it works as expected. The culprit appears to be here:
trait ScalaCheckEffectSuite extends ScalaCheckSuite {
private val initialSeed: Seed =
scalaCheckTestParameters.initialSeed.getOrElse(
Seed.fromBase64(scalaCheckInitialSeed).get
)
This is using 1.0.0-M3
matthughes commented
Looks like Arman already fixed here: 50aa437
Closing.