Cats: Cats testkit based on other testing frameworks?

Created on 4 May 2018  ยท  13Comments  ยท  Source: typelevel/cats

Right now our cats testkit is based on ScalaTest, personally I don't really like that testing library all that much, so it'd be great if we could offer an alternative that's just as integrated for law testing.
I think Monix/minitest would be a good candidate to get this going :) what do you think?

Most helpful comment

Catalysts provides all of this, and has done so for a few years. And was based on work done in cats, spire, algebra, shapeless, etc.

Its fine if folk decide on another solution, but we may well be going round in circles here.

All 13 comments

I'm not a fan of any existing test framework at this point because all of them are side-effecting, but I would definitely prefer something lighter like minitest.

I am curious what people would need from the cats-testkit if they are using minitest. In mainecoon I am using ScalaTest and I don't even need cats-testkit. I think the main feature of cats-testkit is a test base so that you don't have to write import cats.implicits._ in your ScalaTest.

The main feature is setting up law-checking, which isn't even remotely obvious. Also providing a combination of deps that work together. This stuff was always a nightmare in scalaz.

It also comes with discipline integration so you can do checkAll for law tests, which is really the main reason I do it, tbh

discipline comes with cats-laws, you don't need cats-testkit. You can do law-checking without cats-testkit.

maybe we should update the documentation to make this less confusing.

As far as I can tell there is exactly zero doc for discipline so I don't consider it something we can expect people to use directly. So yeah maybe we could fix that.

A better guide for discipline would be extremely useful. As without it being easy to put into place unlawful instances will likely proliferate outside of libraries that have overcome that entry-barrier.

Discipline comes with two tiny parts.
One is to help define hierarchical laws
https://github.com/typelevel/discipline/blob/master/shared/src/main/scala/Laws.scala
The other part is two helpers to generate ScalaTest and Spec2 tests using laws - i.e. the checkAll thing.
The ScalaTest one is like three lines

  def checkAll(name: String, ruleSet: Laws#RuleSet): Unit = {
    for ((id, prop) โ† ruleSet.all.properties)
      test(name + "." + id) {
        check(prop)
      }
  }

I guess what we really need is to provide checkAlls for other test frameworks inside discipline.

~I am modifying the documentation.~
update: PR submitted
https://github.com/typelevel/cats/pull/2245

Catalysts provides all of this, and has done so for a few years. And was based on work done in cats, spire, algebra, shapeless, etc.

Its fine if folk decide on another solution, but we may well be going round in circles here.

Btw, maybe not obvious, but discipline is well documented in the scaladoc.

Picking this up, should we provide cats-testkit-spec2 and cats-testkit-minitest modules that depend on those two testing frameworks instead of ScalaTest? :)

Was this page helpful?
0 / 5 - 0 ratings