@@ -112,20 +112,19 @@ Both `Captor[T]` and `ValCaptor[T]` return an instance of `ArgCaptor[T]` so the
112
112
## ` org.mockito.MockitoScalaSession `
113
113
114
114
This is a wrapper around ` org.mockito.MockitoSession ` , it's main purpose (on top of having a Scala API)
115
- is to filter out the ` $default$ ` stubbings so they are not wrongly reported when we use Strict Stubs
115
+ is to improve the search of mis-used mocks and unexpected invocations to reduce debugging effort when something doesn't work
116
116
117
- To use it just create an instance of it before your test code and call ` finishMocking() ` when your test is done , e.g.
117
+ To use it just wrap your code with it , e.g.
118
118
``` scala
119
- val session = MockitoScalaSession ()
120
-
121
- val foo = mock[Foo ]
122
- when(foo.bar(" pepe" )) thenReturn " mocked"
123
- foo.bar(" pepe" ) shouldBe " mocked"
124
-
125
- session.finishMocking()
119
+ MockitoScalaSession () {
120
+ val foo = mock[Foo ]
121
+ when(foo.bar(" pepe" )) thenReturn " mocked"
122
+ foo.bar(" pepe" ) shouldBe " mocked"
123
+ }
126
124
```
125
+ That's it! that block of code will execute within a session and will handle
127
126
128
- ## ` org.mockito.integrations.scalatest. MockitoFixture`
127
+ ## MockitoFixture
129
128
130
129
For a more detailed explanation read [ this] ( https://medium.com/@bbonanno_83496/introduction-to-mockito-scala-part-3-383c3b2ed55f )
131
130
@@ -139,6 +138,12 @@ the mockito-scala API available in one go, i.e.
139
138
class MyTest extends WordSpec with MockitoFixture
140
139
```
141
140
141
+ In case you want to use the Idiomatic Syntax just do
142
+
143
+ ``` scala
144
+ class MyTest extends WordSpec with IdiomaticMockitoFixture
145
+ ```
146
+
142
147
## ` org.mockito.integrations.scalatest.ResetMocksAfterEachTest `
143
148
144
149
Inspired by [ this] ( https://stackoverflow.com/questions/51387234/is-there-a-per-test-non-specific-mock-reset-pattern-using-scalaplayspecmockito ) StackOverflow question,
0 commit comments