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

@sam-ma sam-ma 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
Copy link

@rratmansky rratmansky 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.

Loading

@thekingn0thing thekingn0thing merged commit 37904cd into powermock:release/2.x Aug 31, 2019
1 check passed
Loading
@helayoty
Copy link

@helayoty helayoty 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?

Loading

msfjarvis added a commit to msfjarvis/Dawn that referenced this issue Oct 17, 2019
As it so happens, the 2.0.4 release of PowerMock is triggering the bug it was supposed to fix[1]

Revert "Bump powermock-api-mockito2 from 2.0.2 to 2.0.4"

This reverts commit c822fd3.

Revert "Bump powermock-module-junit4 from 2.0.2 to 2.0.4"

This reverts commit 9faf5aa.

1: powermock/powermock#997
Tunous added a commit to Tunous/Dawn that referenced this issue Oct 22, 2019
As it so happens, the 2.0.4 release of PowerMock is triggering the bug it was supposed to fix[1]

Revert "Bump powermock-api-mockito2 from 2.0.2 to 2.0.4"

This reverts commit c822fd3.

Revert "Bump powermock-module-junit4 from 2.0.2 to 2.0.4"

This reverts commit 9faf5aa.

1: powermock/powermock#997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants