powermock Questions
4
Recently I was upgrading my project from JDK 11 to JDK 17. After upgrading, powermock seems to have an issue. While running AUT's , I am getting following error:
java.lang.RuntimeException: PowerMo...
Vickievicksburg asked 9/11, 2021 at 10:3
10
Solved
I have the following Logger I want to mock out, but to validate log entries are getting called, not for the content.
private static Logger logger =
LoggerFactory.getLogger(GoodbyeController.clas...
2
I am using Mockito to mock spring beans.
It works fine when I mock an interface.
In our application, there are few @Component beans which do not implement any interface.
When I try to mock such ...
Ecclesiology asked 5/2, 2017 at 7:8
9
I have a folder path set in system variable through JVM arguments in Eclipse and I am trying to access it in my class as:
System.getProperty("my_files_path").
While writing junit test method for...
Equally asked 5/12, 2013 at 15:42
7
Solved
Given a Kotlin singleton object and a fun that call it's method
object SomeObject {
fun someFun() {}
}
fun callerFun() {
SomeObject.someFun()
}
Is there a way to mock call to SomeObject.someF...
Livia asked 22/6, 2016 at 20:7
5
Solved
I am wondering if there is anyway to stub the value of Build.Version.SDK_INT? Suppose I have the following lines in the ClassUnderTest:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BE...
Exterminate asked 28/6, 2016 at 10:52
2
I want to mock a static method m1 from a class which contains 2 static methods, m1 and m2. And I want the method m1 to return an object.
I tried the following
1)
PowerMockito.mockStatic(Static....
2
Let's say I have a non-final concrete class with a final method like the one below.
public class ABC {
public final String myMethod(){
return "test test";
}
}
is it possible to mock myMethod(...
Triglyceride asked 27/8, 2012 at 9:23
2
Solved
I am trying to mock static method using EasyMock+PowerMock. If I dont mock the static method, then I get the exception java.lang.ExceptionInInitializerError but with a different stack trace which i...
Errand asked 30/7, 2016 at 23:29
2
Solved
I want to mock a static interface method with Powermock.
Here's the interface:
public interface IConcurrentUtil {
static void threadSleep(final long millis) {
try {
Thread.sleep(millis);
} cat...
6
How to mock Kotlin extension function using Mockito or PowerMock in tests? Since they are resolved statically should they be tested as static method calls or as non static?
Downes asked 6/6, 2017 at 6:11
3
Solved
Sometimes when I write unit tests I should to mock reference to superclass.
I have read this question:
question
This answer answer with DI advice to refactor code. But I cannot it
this answer an...
Uneasy asked 26/5, 2014 at 8:7
9
I'm having an issue with mockito and powermock, I can mock an abstract class with a final static method with no problems. When trying to mock an Interface as with WebIServerSession I'm getting the ...
Farthing asked 8/11, 2018 at 13:48
6
I am trying to mock static classes(org.apache.commons.beanutils.Beanutils) for Junit 5 test cases. I came across mockito-inline dependency helps with mocking static classes.
I tried to use the mock...
Deryl asked 28/4, 2021 at 11:14
6
Solved
I have been working on an android project and use roboletric and powermock to do unitTests.
When I run gradle jacocoTestReport, it will show
[ant:jacocoReport] Classes in bundle 'app' do no match w...
7
Solved
When using Mockito 1.9.x I have been using Whiteboxto set values of fields to "inject" mocks. Se example below:
@Before
public void setUp() {
eventHandler = new ProcessEventHandler();
securityS...
1
I am getting 3 errors below when trying to mock New Date, using PrepareForTest. How can I fix this?
Reference: https://mcmap.net/q/144856/-how-to-mock-new-date-in-java-using-mockito
java.lang.NoCl...
Schizoid asked 12/12, 2022 at 18:54
6
Solved
I want to mock a static method in JUnit 5. But unfortunately, JUnit 5 doesn’t support Mockito. Is there another method to achieve the same other than reverting back to JUnit 4?
Ploughshare asked 16/10, 2018 at 7:50
5
Solved
I have a few static util methods in my project, some of them just pass or throw an exception. There are a lot of examples out there on how to mock a static method that has a return type other than ...
6
I am using powermock with powermock-easymock-1.5-full.jar. The following exception occurs.
These are the all jars i have in my classpath. And are downloaded as powermock package from http://code.g...
Reddy asked 1/2, 2013 at 10:24
5
Solved
I am working on sonar code coverage using Jacoco plugin and using power mock mockito combination to write JUnit test cases, while all goes well with the build when I run mvn clean install but the c...
Maurilia asked 8/8, 2017 at 6:8
3
This is the test:
import static junit.framework.Assert.assertTrue;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.whenNew;
import ...
Splash asked 10/2, 2011 at 16:3
7
Solved
7
We are using PowerMock in few of our historical projects. Unfortunately PowerMock is quite dead and is not compatible with Java 11.
And we are using mockStatic(). Yes, we know its considered harmf...
Eruptive asked 24/10, 2018 at 10:40
5
Solved
First-timer here, apologies if I've missed anything.
I'm hoping to get around a call to a static method using Spock. Feedback would be great
With groovy mocks, I thought I'd be able to get past th...
Moonshine asked 5/4, 2013 at 1:9
1 Next >
© 2022 - 2025 — McMap. All rights reserved.