typelevel / cats-effect

The pure asynchronous runtime for Scala
https://typelevel.org/cats-effect/
Apache License 2.0
2.03k stars 521 forks source link

`@implicitNotFound` on `Ticker` says to use `ticked` but it's not part of the testkit #1875

Open kubukoz opened 3 years ago

djspiewak commented 3 years ago

I think the text of the @implicitNotFound just needs some tweaking.

jgoday commented 2 years ago

Hi, I'm interested in knowing/learning more about cats and cats-effects, so I started to look after 'good first issue' tasks.

In this case, If I understand it correctly, you can use testkit outside cats-effect but ticked execution method is defined inside the local cats effect tests subproject (cats.effect.Runners trait), so there is no way to use from an external project

For example with a spec like this

"do the things" in {
    val a = unsafeRun(IO(42))
    a.isSuccess must beTrue
}

could the error message be something like ?

could not find an instance of Ticker; You have to add some implicit Ticker to the current scope.

{{{
implicit val ticker: Ticker = Ticker(TestContext())
}}}

One more question, from my ignorance and lack of knowledge about this subject so excuse me if I'm asking something stupid, I understand that Ticker holds the TestContext for some instances, why not just simply require an implicit TestContext instead this Ticker case class ?

armanbilge commented 2 years ago

@jgoday I didn't follow this PR closely, but you may want to take a look at https://github.com/typelevel/cats-effect/pull/2276 which reworked TestContext. I'm actually not sure if this issue is relevant anymore 😅

jgoday commented 2 years ago

Thanks @armanbilge, I will try to follow that thread about TestContext then !