How to use ResetInvocationsTest class of org.mockitousage.basicapi package

Best Mockito code snippet using org.mockitousage.basicapi.ResetInvocationsTest

Run Mockito automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1/*
2 * Copyright (c) 2017 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5package org.mockitousage.basicapi;
6
7import org.junit.Test;
8import org.mockito.Mock;
9import org.mockito.exceptions.misusing.NotAMockException;
10import org.mockitousage.IMethods;
11import org.mockitoutil.TestBase;
12
13import static org.junit.Assert.assertEquals;
14import static org.mockito.Mockito.*;
15
16public class ResetInvocationsTest extends TestBase {
17
18    @Mock
19    IMethods methods;
20
21    @Mock
22    IMethods moarMethods;
23
24    @Test
25    public void reset_invocations_should_reset_only_invocations() {
26        when(methods.simpleMethod()).thenReturn("return");
27
28        methods.simpleMethod();
29        verify(methods).simpleMethod();
30
31        clearInvocations(methods);
32
33        verifyNoMoreInteractions(methods);
34        assertEquals("return", methods.simpleMethod());
35    }
36
37    @Test
38    public void should_reset_invocations_on_multiple_mocks() {
39        methods.simpleMethod();
40        moarMethods.simpleMethod();
41
42        clearInvocations(methods, moarMethods);
43
44        verifyNoMoreInteractions(methods, moarMethods);
45    }
46
47    @Test(expected = NotAMockException.class)
48    public void resettingNonMockIsSafe() {
49        clearInvocations("");
50    }
51
52    @Test(expected = NotAMockException.class)
53    public void resettingNullIsSafe() {
54        clearInvocations(new Object[]{null});
55    }
56}
57
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

...Most popular Stackoverflow questions on ResetInvocationsTest

    No relevant questions found for this class 😞

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)