Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #992 Static mocking broken for Mockito >= 2.26.1 #997

Merged
merged 1 commit into from Aug 31, 2019

Conversation

@sam-ma
Copy link
Contributor

commented Aug 7, 2019

Fix #992. Bump versions of byteBuddy, javassist and mockito.
Known side effect of this fix is that some way of setting up mocks for spy doesn't work. See details below.

spy(System.class);

// This doesn't work
//when(System.nanoTime()).thenReturn(2L);

// This doesn't work
//doReturn(2L).when(System.class, "nanoTime");

// This works
doReturn(2L).when(System.class);
System.nanoTime();
@rratmansky

This comment has been minimized.

Copy link

commented Aug 13, 2019

I implemented this PR locally and still hit the verifyStatic excpetion mentioned in the ticket. Besides updating the libraries as implemented in the PR, is there something else we need to do? I've tried spy(StaticClass.class) and Powermock.mockStatic(StaticClass.class), both result in "Argument passed to verify() is of type Class and is not a mock!" Is there something else that is needed? This is using the powermock rule or with the PowerMockRunner.

@thekingnothing thekingnothing merged commit 37904cd into powermock:release/2.x Aug 31, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@helayoty

This comment has been minimized.

Copy link

commented Sep 12, 2019

I implemented this PR locally and still hit the verifyStatic excpetion mentioned in the ticket. Besides updating the libraries as implemented in the PR, is there something else we need to do? I've tried spy(StaticClass.class) and Powermock.mockStatic(StaticClass.class), both result in "Argument passed to verify() is of type Class and is not a mock!" Is there something else that is needed? This is using the powermock rule or with the PowerMockRunner.

We are running with the same thing and tried out everything. What is the status of this PR now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.