All Questions
Tagged with powermockito powermock
350
questions
0
votes
1
answer
108
views
Issue with using PowerMock to a project which is using Robolectric
I am writing tests for a class which requires Android specific components to be available.
Versions used:
robolectric:4.10.3
powermock: 2.0.9
I am getting this error
Failed to instantiate DeepCloner. ...
0
votes
1
answer
333
views
Power Mock and Mockito Version Incompatible
I'm working on a legacy code base using JDK 1.8.
For one of my unit tests, I want to use PowerMock so that I can call the PowerMock.mockStatic() method on a static method (Provider.provider()) from ...
0
votes
0
answers
85
views
Mockito exeception : java.lang.IllegalStateException: Failed to transform class
I am using JAVA 1.8 with the Javaassist version as 3.23.1 and power mock 1.6.6. I am facing this issue when I am including a class in @PrepareForTest.Here the MainClass class
here is the annotations
@...
1
vote
1
answer
480
views
NoSuchMethodException JDK17 Spring
We are working on migrating the application from jdk11 to jdk17.
As we have to mock final static method we are using powermockrunner. We are using PowerMockito.mockStatic to mock the static class.
If ...
0
votes
0
answers
29
views
Powermock failed to find the 'modifiers' field in method setInternalState [duplicate]
I am trying to run java test cases. Its a spring boot application. When we run the test classes we get "java.lang.RuntimeException: Internal error: Failed to find the 'modifiers' field in method ...
0
votes
1
answer
66
views
Mocked but still null when using PowerMock to mock private method
Here are the brief codes of my project,
class Foo:
public class Foo {
@Autowired
protected Mapper mapper;
protected User getUser() {
// ...
return user;
}
}
class Bar ...
0
votes
1
answer
191
views
How do I mock methods of a private final client that's being initialized inside a dependency class?
I have a class that looks like this :
class A {
private final B b;
public A(String x, String y){
b = new B(x,y);
}
public void someMethod() {
b.externalMethod();
}...
1
vote
1
answer
1k
views
How to mock a static method in scala?
I have a static method in scala and by static method I mean to say that this method is inside an Object named as MyObject. I also have a class named as MyClass where there is a method which calls the ...
0
votes
0
answers
60
views
how to mock a protected method in an abstract class called from BaseClass
Updating the original question.
I will put the original code piece and then put in questions.
Class under test
package my.main.class.package;
public class MyClassHelper extends MySession {
//Session ...
0
votes
1
answer
118
views
How to mock default method of unimplemented interface?
I'm doing some hands on with Junit/Mockito/PowerMockito
I have an interface class
import retrofit2.Call;
import com.learning.model.user.User;
import java.io.IOException;
public interface UserService {...
0
votes
0
answers
107
views
PowerMockitoExtension.class not found
I am using this for my new test cases
@ExtendWith(PowerMockitoExtension.class)
i have added dependencies in my grade as follow
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io....
1
vote
0
answers
114
views
PowerMock.VerifyStatic alternate in mockito
PowerMock.verifyStatic(Util.class)
I use this method in powermockito to verify this class, What is the method I need to use in mockito to verify the similar behaviour ?
0
votes
0
answers
167
views
Why is the PowerMock.whenNew not working here?
I have this simple class:
import java.io.File;
public class TestPowerMock {
public File createFileAndReturnIt() {
return new File("/");
}
}
And this simple test:
import ...
5
votes
1
answer
3k
views
Powermock Failed to find the "modifiers" field in method setInternalState
I am trying to mock static class with Powermock. I am using JDK 14. However I am getting the below error:
Internal error: Failed to find the "modifiers" field in method setInternalState.
...
0
votes
1
answer
50
views
Not getting how to write power mock test cases for below use case
I am having one java code scenario but not getting how to write power mock test cases for that.
Class Test {
ClosableHttpClient c;
}
Class MainTest extends Test{
// code for httpPost and ...