-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
clarify law testing's dependency on cats-testkit and scalatest #2245
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine as far as it goes, but it's still unclear how I would check laws without using CatsSuite
.
@@ -7,23 +7,25 @@ section: "typeclasses" | |||
# Law testing | |||
|
|||
[Laws](https://typelevel.org/cats/typeclasses.html#laws) are an important part of cats. | |||
Cats uses `catalysts` and `discipline` to help test instances with laws. | |||
To make things easier, cats ships with `cats-testkit`, which makes use of `catalysts` and `discipline` and exposes `CatsSuite` based on ScalaTest. | |||
Cats uses `catalysts` and [discipline](https://github.com/typelevel/discipline) to help test instances with laws. To test type class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is catalysts
relevant here?
Then we can begin to write our law tests. Start by creating a new class in your `test` folder and inheriting from `cats.tests.CatsSuite`. | ||
`CatsSuite` extends the standard ScalaTest `FunSuite` as well as `Matchers`. | ||
Then we can begin to write our law tests. If you are using `ScalaTest` you can inherit from `cats.tests.CatsSuite` | ||
from `cats-testkit`. `CatsSuite` extends the standard ScalaTest `FunSuite` as well as `Matchers`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you do if you're not using ScalaTest? Not sure this helps.
Codecov Report
@@ Coverage Diff @@
## master #2245 +/- ##
==========================================
+ Coverage 94.95% 94.96% +0.01%
==========================================
Files 333 333
Lines 5787 5799 +12
Branches 222 217 -5
==========================================
+ Hits 5495 5507 +12
Misses 292 292
Continue to review full report at Codecov.
|
@tpolecat how about now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Now I finally understand how it works! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is great! 😊
the [ScalaCheck](https://github.com/rickynils/scalacheck) tests based on them. | ||
|
||
To test type class laws from Cats against your instances, you need to add a `cats-laws` dependency. | ||
If you are using `ScalaTests`, Cats also ships with optional `cats-testkit`, which provites a convenient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo ScalaTests
made some tut compilation corrections. need a quick re-review. |
```tut:book | ||
implicit def eqTree[A: Eq]: Eq[Tree[A]] = Eq.fromUniversalEquals | ||
```tut:invisible | ||
import Tree._ //there is no real companion object is in REPL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/is in/in the/
No description provided.