-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3596e0
commit 51feb59
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
shared/src/test/scala/org/scalamock/test/scalatest/AbstractOverrideMethodTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |