You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to discuss a new feature, please ignore/clear this form.
ScalaMock Version (e.g. 3.5.0)
6.0.0
Scala Version (e.g. 2.12)
3.4.2
Runtime (JVM or JS)
JVM
Please describe the expected behavior of the issue
Consider the following code:
importorg.scalamock.scalatest.MockFactoryimportorg.scalatest.TestSuite// macwire taggingtraitTag[+U] extendsAny { typeTag<:U }
type@@[+T,+U] =TwithTag[U]
implicitclassTagger[T](valt:T) extendsAnyVal {
@inline deftaggedWith[U]:T@@U= t.asInstanceOf[T@@U]
}
// examplecaseclassCacheApi()
traitSettingsCachetraitDataCachecaseclassController(settingsCache: CacheApi@@SettingsCache)
// how this may be used in the real appobjectRealContext {
valsettingsCache:CacheApi@@SettingsCache=CacheApi().taggedWith[SettingsCache]
valdataCache:CacheApi@@DataCache=CacheApi().taggedWith[DataCache]
valcontoller=Controller(settingsCache)
}
// how this is used in teststraitTestContextextendsMockFactory {
this:TestSuite=>valcontroller= mock[Controller]
}
This code correctly mocks Controller in Scala 2.13, but fails in Scala 3 with a message:
Hi, thank you for reporting. It surely was supported in scala 2, but I'm not sure it should be fixed for scala 3, IMO you are doing something wrong.
You should mock interfaces not implementations.
Consider using Dependency Inversion principle and make your implementations depend on interfaces. It will make your test cases simpler and life easier.
If you want to discuss a new feature, please ignore/clear this form.
ScalaMock Version (e.g. 3.5.0)
6.0.0
Scala Version (e.g. 2.12)
3.4.2
Runtime (JVM or JS)
JVM
Please describe the expected behavior of the issue
Consider the following code:
This code correctly mocks
Controller
in Scala 2.13, but fails in Scala 3 with a message:Scala 3 playground: https://scastie.scala-lang.org/mrSdYwvmSi2yz9daKC4neA
Scala 2.13 playground: https://scastie.scala-lang.org/jv7RKjqtTV2FUycZyME6MQ
The text was updated successfully, but these errors were encountered: