How to use DiamondInheritanceIsConfusingMockitoTest class of org.mockitousage.bugs package

Best Mockito code snippet using org.mockitousage.bugs.DiamondInheritanceIsConfusingMockitoTest

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.bugs;
6
7
8import org.junit.Assert;
9import org.junit.Test;
10import org.mockito.Mockito;
11
12
13// see #508
14public class DiamondInheritanceIsConfusingMockitoTest {
15    @Test
16    public void should_work() {
17        DiamondInheritanceIsConfusingMockitoTest.Sub mock = Mockito.mock(DiamondInheritanceIsConfusingMockitoTest.Sub.class);
18        // The following line results in
19        // org.mockito.exceptions.misusing.MissingMethodInvocationException:
20        // when() requires an argument which has to be 'a method call on a mock'.
21        // Presumably confused by the interface/superclass signatures.
22        Mockito.when(mock.getFoo()).thenReturn("Hello");
23        Assert.assertEquals("Hello", mock.getFoo());
24    }
25
26    public class Super<T> {
27        private T value;
28
29        public Super(T value) {
30            this.value = value;
31        }
32
33        public T getFoo() {
34            return value;
35        }
36    }
37
38    public class Sub extends DiamondInheritanceIsConfusingMockitoTest.Super<String> implements DiamondInheritanceIsConfusingMockitoTest.iInterface {
39        public Sub(String s) {
40            super(s);
41        }
42    }
43
44    public interface iInterface {
45        String getFoo();
46    }
47}
48
49
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 DiamondInheritanceIsConfusingMockitoTest

    No relevant questions found for this class 😞

Most used methods in DiamondInheritanceIsConfusingMockitoTest

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)