Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
44 views

How to mock Files API from java.nio.file.*

I am using Java nio API and have a below code, but unable to perform mocking on the below code. Path path = Paths.get(filePath); long sizeInBytes = Files.size(path); long recordCount = 0; try (Stream&...
PAA's user avatar
  • 11.5k
0 votes
0 answers
14 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 ...
Joe1988's user avatar
  • 141
0 votes
0 answers
128 views

How to mock Constructor in mockito 5.2.0

I'm upgrading PowerMockito to Mockito 5.2.0, While upgrading, I am facing an issue with mocking the constructor. I have tried many ways to mock the constructor, Can someone let me know how we can ...
priyanshi sahu's user avatar
0 votes
0 answers
27 views

PowerMock not using mocked "new" object

I have a Spring Boot project and trying to use PowerMockito to mock an object that is created inside the method. I have some code that is declaring a new Object that is extending an Abstract class: @...
SS123's user avatar
  • 3
0 votes
0 answers
182 views

CGLIB$SET_THREAD_CALLBACKS([Lorg.springframework.cglib.proxy.Callback) :

Some Junit Test cases are failing when running all test classes together but passing individually. **Caused by: java.lang.NoSuchMethodException: xxx.zzz$$SpringCGLIB$$0.CGLIB$SET_THREAD_CALLBACKS([...
Ashvinee Pawar's user avatar
0 votes
0 answers
24 views

How to return different values with the same method call in the same class in a loop?

I am looping over a list table names to do the following Call describe table to check if the table exists If the table doesn't exist, throw ResourceNotFoundException. Call createTable method to ...
Mojo jojo's user avatar
0 votes
1 answer
82 views

MockitoJUnitRunner throws NullPointerException while instantiating AppCompatActivity

I am trying to mock an Activity which extends AppCompatActivity using the MockitoJUnitRunner. I understand that I should use Instrumentation Test to test the activities in Android. Here I just want to ...
Raj's user avatar
  • 496
0 votes
0 answers
74 views

JUnit powermock throw exception IllegalAccessError:cannot clear JavaAgentClassRegister

In java,use powermock to test.There are 3 projects in my workspace. Two of them has been run without any problem.But last one throw Exception java.lang.IllegalStateException: Cannot clear ...
user22520757's user avatar
1 vote
1 answer
121 views

How to mock overloaded public static method which returns void with PowerMockito

I got a problem mocking a public static method which returns void, when I want it to throw specific Exception (e.g. RuntimeException) This is what I have so far: @RunWith(PowerMockRunner.class) @...
Saša's user avatar
  • 4,676
0 votes
1 answer
99 views

How to write test case using vertx for db class?

Below is my written code. I want to write test cases using powermokito for db class. I expect to write test cases for below vertx related classess using junit powermokito to cover 80% coverage. I ...
Kalpani Athukorala's user avatar
1 vote
0 answers
183 views

How to write a test for a class which has a method and parameter in this method is of ServiceBusReceivedMessageContext?

I am not able to write test case for a class which has a function and that function has ServiceBusReceivedMessageContext as the parameter. ServiceBusReceivedMessageContext class is final class.Can ...
Shubham Singh's user avatar
0 votes
1 answer
58 views

Problem on mock new Object using PowerMockito

Basically i have a class, TwsConnector, with 1 method, that provide a connection via REST call to a client that schedule a job. This is the class: @Service public class TwsConnector { @Autowired ...
EZDM's user avatar
  • 3
0 votes
1 answer
296 views

Why does StepVerifier.verifyComplete() is going into infinite loop when I use Scheduler and the test completes when I remove scheduler?

I am trying to test orchestrator flow which is using Reactor Mono. When I am testing the flow using StepVerifier the test was never finished. If I remove publishOn(myThreadDispatcher) then the test is ...
Lokesh Reddy's user avatar
0 votes
1 answer
76 views

Junit giving error related to private access in a class FilesMgr and as well as thenReturn(FileStatus)

Junit giving error related to private access in a class FilesMgr and as well as thenReturn(FileStatus) Hello All, Here is the below original class, I've written Junit for getFilesWithSizes() method. ...
Dheeru's user avatar
  • 1
0 votes
0 answers
29 views

Convert powermockito testcase code into testng testcase

Here I am using whenNew method in powermockito. @Test public void test() { MsgTransmit msgtransmit= mockm(MsgTransmit.class); String userId= id101; Powermockito....
Keerthi Senthil's user avatar

15 30 50 per page
1
2 3 4 5
32