Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Property testing framework inspired by quickcheck
- 2. Difference between unit testing vs property tests
- 3. Fundamental testing unit is a property. Property consists of input domain, computation, assertion
- 4. TDD
- import org.scalacheck.Prop.forAll
- val prop1 = forAll { x: Int => println(x); x == x}
- prop1.check
- def sort(xs: List[Int]) = xs.sorted
- forAll {xs: List[Int] =>
- val xs_ = sort(xs)
- val containsAll = (xs.toSet -- xs_.toSet).isEmpty
- if(xs.size == 1) containsAll
- else containsAll && xs_.sliding(2).forall(x => x(0) < x(1))
- }
Add Comment
Please, Sign In to add comment