typelevel / weaver-test

A test framework that runs everything in parallel.
https://typelevel.org/weaver-test/
Other
45 stars 8 forks source link

IOSuite test suite extended by MockFactory (scalamock) never executes #96

Open zainab-ali opened 14 hours ago

zainab-ali commented 14 hours ago

This issue was copied over from: https://github.com/disneystreaming/weaver-test/issues/640 It was opened by: DenisNovac


Weaver version: "0.8.1" Scalamock version: "5.2.0"

In build.sbt:

testFrameworks += new TestFramework("weaver.framework.CatsEffect")

Example code:

class MySpec(global: GlobalRead) extends IOSuite with LowPriorityImplicits with MockFactory { 
   test("test") { _ => expect(true) }
}

Test "test" will never be called while suite is extended by MockFactory. If you remove with MockFactory - it will work fine.

zainab-ali commented 14 hours ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/640#issuecomment-1465972994 It was written by: Baccata


Hi. Thanks for raising an issue for visibility.

In all frankness and at the risk of disappointing you, this is not something that I will dedicate time to investigate. If you find the root cause of the issue, and a potential fix, I'll happily look at a PR though :)

zainab-ali commented 14 hours ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/640#issuecomment-1466060872 It was written by: DenisNovac


Hello, sure, it's ok, i was just wondering if anyone already had similar problem and fixed it somehow.

zainab-ali commented 14 hours ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/640#issuecomment-1484035299 It was written by: DenisNovac


As a workaround i used MockitoCats from mockito-scala instead of ScalaMock. This library doesn't depend on scala's test frameworks so it worked out for me.

zainab-ali commented 14 hours ago

This comment was copied over from: https://github.com/disneystreaming/weaver-test/issues/640#issuecomment-2338925097 It was written by: kubukoz


The issue is that the MockFactory you're using is probably scalatest-specific. Instead, you should extend org.scalamock.MockFactoryBase (which is framework-agnostic) and implement the newExpectationException function.

Not a great implementation but this should get you going:

  type ExpectationException = Throwable

  protected def newExpectationException(message: String, methodName: Option[Symbol]): ExpectationException =
    new Throwable(s"$methodName: $message")