scalaTest AsyncSpec with PropertyChecks.

285 views
Skip to first unread message

cjk

unread,
Jul 13, 2016, 4:31:31 PM7/13/16
to scalatest-users
I ran into 2 issues using scalaTest-3.0.0-RC4

Issue 1

class AbcTest extends PropSpec with BeforeAndAfter with PropertyChecks {
}

Results in compiler error

Information:7/13/16 3:19 PM - Compilation completed with 1 error and 0 warnings in 1s 64ms
Error:scalac: missing or invalid dependency detected while loading class file 'GeneratorDrivenPropertyChecks.class'.
Could not access type Gen in value org.scalacheck,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'GeneratorDrivenPropertyChecks.class' was compiled against an incompatible version of org.scalacheck.


Continuing

class AbcTest extends PropSpec with BeforeAndAfter with PropertyChecks {

property("test1") {
      forAll(Table(...)) { resp => 
        functionReturningFutureBoolean().map { r => assert(r) }

}
}

This one passes even when r is false.


Then lastly, I wanted to use AsyncFunSpec, which needs each test to return an assertion or Future of assertion. 
But in this case forAll returns unit. (forAll is the last statement in the test)
Is there anyway to bypass this and use AsyncFunSpec with PropertyChecks?


Bill Venners

unread,
Jul 13, 2016, 4:53:12 PM7/13/16
to scalate...@googlegroups.com
Hi,

On Wed, Jul 13, 2016 at 1:31 PM, cjk <chai...@gmail.com> wrote:
> I ran into 2 issues using scalaTest-3.0.0-RC4
>
> Issue 1
>
> class AbcTest extends PropSpec with BeforeAndAfter with PropertyChecks {
> }
>
> Results in compiler error
>
> Information:7/13/16 3:19 PM - Compilation completed with 1 error and 0
> warnings in 1s 64ms
> Error:scalac: missing or invalid dependency detected while loading class
> file 'GeneratorDrivenPropertyChecks.class'.
> Could not access type Gen in value org.scalacheck,
> because it (or its dependencies) are missing. Check your build definition
> for
> missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see
> the problematic classpath.)
> A full rebuild may help if 'GeneratorDrivenPropertyChecks.class' was
> compiled against an incompatible version of org.scalacheck.
>
This may be a version mismatch with ScalaCheck. It suggests a full
rebuild, which I'd try first. If that doesn't fix it, then double
check the version numbers. The version numbers for 3.0.0-RC4 you can
look up in the POM, here:

https://oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.11/3.0.0-RC4/scalatest_2.11-3.0.0-RC4.pom

>
> Continuing
>
> class AbcTest extends PropSpec with BeforeAndAfter with PropertyChecks {
>
> property("test1") {
> forAll(Table(...)) { resp =>
> functionReturningFutureBoolean().map { r => assert(r) }
>
> }
> }
>
> This one passes even when r is false.
>
That's because this isn't an async style. You can only map assertions
onto futures in async styles.

>
> Then lastly, I wanted to use AsyncFunSpec, which needs each test to return
> an assertion or Future of assertion.
> But in this case forAll returns unit. (forAll is the last statement in the
> test)
> Is there anyway to bypass this and use AsyncFunSpec with PropertyChecks?
>
Not yet, which is why we didn't yet release AsyncPropSpec. That's on
the list of things to do in the future, but we haven't done it yet.
That means that to do property based tests involving futures, you'll
still need to block. That further means that you can't do that on
Scala.js yet, if that's what you are trying to do, because you can't
block on Scala.js.

Bill
>
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
> ---
> You received this message because you are subscribed to the Google Groups
> "scalatest-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scalatest-use...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com
Reply all
Reply to author
Forward
0 new messages