#Mockito mock on abstract class

1 messages · Page 1 of 1 (latest)

copper lichen
#
import static org.mockito.Answers.CALLS_REAL_METHODS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public abstract class IssouTest {
    private int id;

    public int getId() {
        return id;
    }

    public int getId2() {
        return getId();
    }

    public static void main(String[] args) {
        IssouTest a = mock(CALLS_REAL_METHODS);
        when(a.getId()).thenReturn(1);
        
        // why is this false ?
        System.out.println(a.getId2()== 1);
    }
}

why this is not true

teal jacinthBOT
#

This post has been reserved for your question.

Hey @copper lichen! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

copper lichen
#

Mockito mock on abstract class