Last active
December 28, 2015 15:19
-
-
Save zenlambda/7520515 to your computer and use it in GitHub Desktop.
While working on assignment 2 for the "Reactive Programming with Scala course" I got frustrated with the ScalaCheck library. It's difficult to get it to print out the name of the failing property (in this case "scalatest doc property"). Nor can you seem to print out argument names as the scalatest documentation suggests [1]. http://www.scalatest…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[info] ScalaTestSuite: | |
[info] - scalatest property test *** FAILED *** | |
[info] GeneratorDrivenPropertyCheckFailedException was thrown during property evaluation. | |
[info] (ScalaTestSuite.scala:12) | |
[info] Falsified after 0 successful property evaluations. | |
[info] Location: (ScalaTestSuite.scala:12) | |
[info] Occurred when passed generated values ( | |
[info] arg0 = "", | |
[info] arg1 = "" | |
[info] ) | |
// failing "scalatest doc property" is not mentioned anywhere in this error! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package simulations | |
import org.scalacheck.Properties | |
import org.scalacheck.Prop.forAll | |
class ScalaCheckProperties extends Properties("Properties from ScalaTest Docs") { | |
// based on example "supply argument names" property from: | |
// http://www.scalatest.org/user_guide/generator_driven_property_checks | |
property("scalatest doc property") = forAll { (a: String, b: String) => | |
a.length + b.length == ((a + b).length + 1) // Should fail | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package simulations | |
import org.scalatest.FunSuite | |
import org.scalatest.prop.Checkers | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
@RunWith(classOf[JUnitRunner]) | |
class ScalaTestSuite extends FunSuite with Checkers { | |
test("scalatest property test") { | |
check(new ScalaCheckProperties) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment