Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Munit property tests do not get executed #204

Open
ciuncan opened this issue Apr 4, 2021 · 0 comments
Open

Munit property tests do not get executed #204

ciuncan opened this issue Apr 4, 2021 · 0 comments

Comments

@ciuncan
Copy link

ciuncan commented Apr 4, 2021

I have an doctest like the one below:

    /**
     * {{{
     * scala> import java.util.UUID
     *      | import com.mypackage.implicits.SeqImplicits.RichIterable
     *
     * prop> (s: Seq[UUID], n: Int) => (0 <= n && n <= s.size) ==> (s.sampleN(n).size == n)
     */
     def sampleN(n: Int): Vector[Int] = ...

But since the test code is generated as below:

class SeqImplicitsDoctest extends ScalaCheckSuite {

  def sbtDoctestTypeEquals[A](a1: => A)(a2: => A): _root_.scala.Unit = {
    val _ = () => (a1, a2)
  }
  def sbtDoctestReplString(any: _root_.scala.Any): _root_.scala.Predef.String = {
    val s = _root_.scala.runtime.ScalaRunTime.replStringOf(any, 1000).init
    if (s.headOption == Some('\n')) s.tail else s
  }

  test("SeqImplicits.scala:275: sampleN") {
    import java.util.UUID
    import com.mypackage.implicits.SeqImplicits.RichIterable

  property("property at line 282: (s: Seq[UUID], n: Int) => (0 <= n && n <= s.size) ==> (s.sam ...") {
    forAll((s: Seq[UUID], n: Int) => (0 <= n && n <= s.size) ==> (s.sampleN(n).size == n))
  }
  }

}

The property-based test do not get executed. If I understood Munit's property method correctly, it registers a property-based test. But here it happens inside of another test which is now getting executed, it is now too late.

I looked into trait TestGen but the current architecture doesn't appear to be compatible with the way Munit expects property-based tests. That is, the abstract generatePropertyExample method is used at the same level as generateExample which only gets placed inside generateTestCase as the test body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant