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

clarify law testing's dependency on cats-testkit and scalatest #2245

Merged
merged 10 commits into from
May 10, 2018

Conversation

kailuowang
Copy link
Contributor

No description provided.

Copy link
Member

@tpolecat tpolecat left a 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
Copy link
Member

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`.
Copy link
Member

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-io
Copy link

codecov-io commented May 7, 2018

Codecov Report

Merging #2245 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
.../src/main/scala/cats/syntax/applicativeError.scala 100% <0%> (ø) ⬆️
core/src/main/scala/cats/syntax/flatMap.scala 82.6% <0%> (+15.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eba9a59...fd77b9c. Read the comment docs.

@kailuowang
Copy link
Contributor Author

@tpolecat how about now?

tpolecat
tpolecat previously approved these changes May 7, 2018
Copy link
Member

@tpolecat tpolecat left a 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! 👍

LukaJCB
LukaJCB previously approved these changes May 8, 2018
Copy link
Member

@LukaJCB LukaJCB left a 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! 😊

@kailuowang kailuowang dismissed stale reviews from LukaJCB and tpolecat via 329e5ae May 8, 2018 14:43
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo ScalaTests

@kailuowang
Copy link
Contributor Author

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
Copy link
Member

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/

@kailuowang kailuowang merged commit cb38e99 into master May 10, 2018
@kailuowang kailuowang added this to the 1.2 milestone May 30, 2018
@kailuowang kailuowang deleted the kailuowang-patch-2 branch June 19, 2018 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants