Questions tagged [mockitowhen]

4 questions
3
votes
2 answers

Mockito when and verify method difference

I just need to know 1) when I call when() in Mockito, it is actually executing the mockedObject method behaviour or not? 2) what If when I return a wrong value in when().thenReturn() like below. The test case will be "false" or will it return 50…
anand krish
  • 4,281
  • 4
  • 44
  • 47
0
votes
1 answer

Mockito.when won't work inside Test method body

I'm trying to test that Invoice class I made. Works so far, but I have a problem inside of the falsePayCallKeepsPaidAtFalse method. The Mockito.when method does not have any impact on the actual return value. Mockitor.when does only work inside of…
PRenkel
  • 13
  • 3
0
votes
1 answer

Mockito NoSuchElementException when() findById() get() thenReturn()

Trying to test my service with Mockito library, and I bumped into a problem, please see below the error: java.util.NoSuchElementException: No value present at java.util.Optional.get(Optional.java:135) at…
Szelek
  • 2,629
  • 5
  • 17
  • 25
0
votes
1 answer

Mockito.when evaluates expression

I have a JUnit test written for a function that creates an s3 client, fetches data to parse it. So, I have a class called M, P and M's test class MTest. MTest has annotation @RunWith(MockitoJUnitRunner.class) on top. P's object is a member…
Him
  • 318
  • 3
  • 11