Skip to main content
0 votes
0 answers
24 views

Mockito Test Method Transport.send inside completable future

So I'm struggling with writing a mockito test method for a method having this piece of code Future<?> future = executor.submit(() -> { try { ...
Bhavya Sai Kamasamudram's user avatar
0 votes
1 answer
67 views

Mock new Date or System.currentTimeMillis

I am setting up tests using Groovy and the Spock framework. My tests depend on the passage of time, and the services in question use new Date() for some rules. Because of this, I would like to modify ...
felipe mota effting's user avatar
0 votes
0 answers
15 views

How to mock Files.walk(Paths.get(dropLocation))) using mockito?

How can we mock the below method using mockito? public static List<File> getFilesPath(String dropLocation) throws IOException{ try(Stream<Path> streamPath = Files.walk(Paths.get(...
PAA's user avatar
  • 11.8k
0 votes
1 answer
63 views

Use PowerMock to mock java.io.File not effectively

I have code such as: File file = File createTempFile(“xxx”, “txt”); So, when I use PowerMock to mock this file object, such as: @RunWith(PowerMockRunner.class) @PrepareForTest({File.class,StringUtils....
Chenet Chen's user avatar
0 votes
0 answers
15 views

android - unit test spy behavior different between Mokito and PowerMokito

Below two case pass test but why the times is different? Mokito case is 1 and 1 but PowerMokito case is 2 and 1 for the add api call. package com.example; import static org.junit.Assert.assertEquals; ...
lucky1928's user avatar
  • 8,751
0 votes
0 answers
52 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.8k
0 votes
0 answers
40 views

InvocationTargetException when using PowerMockito to test Static Methods

I have a final class ConfigurationManager that has a method getProps(CONF). I have to mock and return "true" when this method is called. public final class ConfigurationManager { ...
John K Jose's user avatar
0 votes
1 answer
72 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. ...
SyntaxSage's user avatar
0 votes
0 answers
42 views

Mockito MockedStatic Object, pass as an argument to class

Unable to pass type MockedStatic object into method/ constructor I have this legacy code - class Mom { Mom(Class StaticBaby){ } } I've used Mockito's mockstatic (v5.12) to mock out StaticBaby ...
user24031969's user avatar
0 votes
0 answers
15 views

ArgumentCaptor works on String type but fail on Intent type

I have a function with two argument, one is android Intent, another one is String. I use ArgumentCaptor to capture it but the Intent Object verify fail, the String one works fine. Error: Expected :...
lucky1928's user avatar
  • 8,751
0 votes
1 answer
37 views

Mocking an object without a getter

I want to mock a function that has following code - // Getting all ad insights objects from API Connection<AdsInsights> insightsConnection = facebookClient.fetchConnection( adAccountId + ...
ujjawal's user avatar
0 votes
1 answer
233 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 ...
TechGoose's user avatar
0 votes
0 answers
28 views

How to read the written data from the Servlet's Response [duplicate]

1.Now, I have this Response object, and I'm using the Response.getWriter object to write to it and some JSON data. PrintWriter writer = response.getWriter(); writer.write("hello world"); ...
沐雨听风's user avatar
0 votes
0 answers
56 views

maven build/verify scanning class but not showing in coverage report

Trying to generate jacoco code coverage report , test class is getting scanned but getting below warning : [WARNING] Classes in bundle '<module_name>' do not match with execution data. For ...
Gunjan SHrivastava's user avatar
0 votes
0 answers
78 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 @...
Saurabh Raj's user avatar

15 30 50 per page
1
2 3 4 5
88