Skip to content

Conversation

ChristianSchwarz
Copy link
Contributor

The enum type Answers implements now the Answer interface. This allows us to use the enum values in Mockito.mock(Class,Answer). This is handy when you have to test legacy code with PowerMockito and want to use both @Mock and Mockito.mock(..).

@Mock(answers=RETURNS_DEEP_STUBS) 
ClassA a;
ClassB b;

public void setUp(){
  b= mock(ClassB,Mockito.RETURNS_DEEP_STUBS)   //<< static import is not possible here, but with this pull request we can use RETURNS_DEEP_STUBS we used in @Mock.
}

@bric3
Copy link
Contributor

bric3 commented Dec 30, 2014

Good idea I like it.
Also the IDE changed too much whitespaces, to see the relevant change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backward compatibility I propose to keep the get() method and add the @Deprecated annotation, also adding a documentation explaining how this method can be replaced and that this method will be removed in a future version.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) when pulling 621d945 on ChristianSchwarz:master into 8fc0388 on mockito:master.

@bric3 bric3 merged commit 621d945 into mockito:master Jan 2, 2015
@bric3
Copy link
Contributor

bric3 commented Jan 2, 2015

Thanks for the change

@bric3 bric3 added this to the 2.1 milestone Aug 30, 2016
neworld pushed a commit to neworld/mockito that referenced this pull request Aug 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants