-
Notifications
You must be signed in to change notification settings - Fork 2
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
19627d6
commit 0d3c4a4
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
testing/src/main/java/ar/com/wolox/wolmo/testing/mockito/MockitoVerificationHelper.kt
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,49 @@ | ||
package ar.com.wolox.wolmo.testing.mockito | ||
|
||
import org.mockito.Mockito | ||
import org.mockito.Mockito.atLeastOnce | ||
import org.mockito.Mockito.times | ||
|
||
/** | ||
* Use this method to verify a certain behavior happened just a single time. | ||
* | ||
* @param mock the mocked class. | ||
* <pre>{@code | ||
* verifyOnce(mockedClass).expectedBehavior()} | ||
* </pre> | ||
*/ | ||
fun <T> verifyOnce(mock: T): T = | ||
Mockito.verify(mock, times(1)) | ||
|
||
/** | ||
* Use this method to verify a certain behavior happened at least one time. | ||
* | ||
* @param mock the mocked class. | ||
* <pre>{@code | ||
* verifyAtLeastOnce(mockedClass).expectedBehavior()} | ||
* </pre> | ||
*/ | ||
fun <T> verifyAtLeastOnce(mock: T): T = | ||
Mockito.verify(mock, atLeastOnce()) | ||
|
||
/** | ||
* Use this method to verify a certain behavior did not happen at all. | ||
* | ||
* @param mock the mocked class. | ||
* <pre>{@code | ||
* verifyZeroTimes(mockedClass).unexpectedBehavior()} | ||
* </pre> | ||
*/ | ||
fun <T> verifyZeroTimes(mock: T): T = | ||
Mockito.verify(mock, times(0)) | ||
|
||
/** | ||
* Use this method to verify a certain behavior happened a custom number of times. | ||
* | ||
* @param mock the mocked class. | ||
* <pre>{@code | ||
* verifyCustomTimes(mockedClass, 3).expectedBehavior()} | ||
* </pre> | ||
*/ | ||
fun <T> verifyCustomTimes(mock: T, times: Int) = | ||
Mockito.verify(mock, times(times)) |