From 51feb59d52c538573e89e551102ff288155b6348 Mon Sep 17 00:00:00 2001 From: Hugh Simpson Date: Thu, 1 Aug 2024 12:48:11 +0100 Subject: [PATCH] Add failing test --- .../scalatest/AbstractOverrideMethodTest.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 shared/src/test/scala/org/scalamock/test/scalatest/AbstractOverrideMethodTest.scala diff --git a/shared/src/test/scala/org/scalamock/test/scalatest/AbstractOverrideMethodTest.scala b/shared/src/test/scala/org/scalamock/test/scalatest/AbstractOverrideMethodTest.scala new file mode 100644 index 00000000..ca8e9c55 --- /dev/null +++ b/shared/src/test/scala/org/scalamock/test/scalatest/AbstractOverrideMethodTest.scala @@ -0,0 +1,18 @@ +package org.scalamock.test.scalatest + +import org.scalamock.scalatest.MockFactory +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class AbstractOverrideMethodTest extends AnyFlatSpec with Matchers with MockFactory { + class A extends B with D + trait B extends C { def foo(): Int = 1 } + trait C { def foo(): Int } + trait D extends C { abstract override def foo(): Int = super.foo() * 2 } + + "ScalaTest suite" should "permit mocking classes build with stackable trait pattern" in { + val mockedClass = mock[A] + (mockedClass.foo _).expects().returning(42) + mockedClass.foo() shouldBe 42 + } +}