PermGen size error when generating Cobertura report

I ram running into issue where my application throws PermGen size error whenever I generate cobertura report using this command clean cobertura:cobertura. I have the tried almost everything such as the following: Increase permgen size in sts.ini Incr

Make fun of an object that is part of a mocked object

when I run the test case I get AnObj mocked. this is used from inside the target classes method. when that method gets invoked the 'anOtherObj' is accessed and that is found to be null. Can some one please point out how to make sure 'anOtherObj' is n

Junit - mock a file

I'm trying to cover code that process a file. I'm trying to avoid using real file for tests, so I'm using Mockito. This is the code I'm trying to test: try { byte[] data = Files.readAllBytes(((File) body).toPath()); immutableBody = data; actualHeader

How to solve the exception Stubbing Unneccessary

My Code is as below, @RunWith(MockitoJUnitRunner.class) public class MyClass { private static final String code ="Test"; @Mock private MyClassDAO dao; @InjectMocks private MyClassService Service = new MyClassServiceImpl(); @Test public void test

Mockito - Injection of a list of false pretenses

I have the following code: @Component public class Wrapper { @Resource private List<Strategy> strategies; public String getName(String id) { // the revelant part of this statement is that I would like to iterate over "strategies" return st

Mockito throws the exception

public interface ABC { public boolean removeUser(String userId) throws OTPServiceException, RemoteException; } ABC abc= mock(ABC.class); doNothing().when(abc).removeUser(anyString()); I have tried like this. I got below exception. org.mockito.excepti

How to generate an android.jar to make fun?

Now I need a mockable android.jar. I had ever seen a android.jar before generated automatically by mockito or gradle or android studio. How I can generate it in gralde task? I try ./gradlew mockableAndroidJar, but not android.jar finded.I don't think

How to use @InjectMocks with @Autowired annotation in Junit

I have a class A which is using 3 differnt classes with autowiring public class A () { @Autowired private B b; @Autowired private C c; @Autowired private D d; } While testing them, i would like to have only 2 of the classes (B & C) as mocks and have

How to deal with Setter / Getter-Mocks methods?

So I am still having trouble with the usage of Mockito. So let's assume I have following class (Please ignore the logic, or structure of it, it's just a short example I created from another class, with different names and so on.) : public class Resta

Mockito returns the same result for different parameter values

I get this weird behaviour with Mockito but I m not sure if it is the expected behaviour in any manner :-(. Following code is a fictitious Java code I came up with to highlight the point. import org.junit.Test; import org.mockito.Mockito; import java

How to test an empty method using JUnit and Mockito?

My void method changes boolean variable value in the class. How do DI check that? I have: mocked class object called the method with proper parameters checked the instance variable But that doesn't change the value of instance variable. How do I do t

Using Mockito and PowerMockito for CAD testing

I want to test my DAO methods using Mockito (and PowerMockito if needed), but I don't know how to do this. The biggest problem with calling static method (MySQLDAOFactory.getConnection() in MySQLStationDAO). Can you help me? I obtain connection this

Why do I need mockito to test Spring apps?

Im trying to understand how all things are related with Spring. However I do not understand why mockito is used when unit testing spring code? Can not spring handle to same DI that mockito does? What is it that mockito contributes that is not possibl

Super class abstract class mocking field

I have an abstract class: public abstract MySuperEpicAbstractClass { @Autowired private IMessageWriter messageWriter; protected IMessageWriter getMessageWriter() { return messageWriter; } } public abstract class MyEpicAbstractClass extends MySuperEpi

Mockito allows you to set the simulated return value

Is it possible to change the value that is returned from a mocked object? Below is an example that explains what I am trying to do. public class MyClass{ public void method(Mock obj){ if(obj.getValue.equals("value"){ obj.setValue("changedVa

Make fun of a dependency on a properties file

I'm trying to write a unit test that involves using legacy code. Problem is, from what I can tell, the legacy code uses a key/value pair from a property file to initialize one of its final static private members, and I haven't the slightest as to whe

Mockito's answer in ScalaTest

Is there some alternative to Mockito's Answer in ScalaTest? I was going through its documentation, but didn't find anything. I would like to, for example, execute some logic on arguments of a stubbed method. In Mockito, I would do something like this

Erro Unit Test [Wanted but not summoned] mockito

Doubt: Good Night, I'm doing some testing on my service and I'm having trouble performing the test in the delete method. I wonder if anyone ever had this error and can be helping me. The error occurs when I do the scan. What is reported is that the m

How to use mockito to test a REST service?

I am very new in Java Unit Testing and I heard that Mockito framework is really good for testing purposes. I have developed a REST Server (CRUD methods) and now I want to test it, but I don't know how? Even more I don't know how this testing procedur

Mockito Matcher and painting of primitives

With Mockito, I want to verify() a method call with byte[] in its argument list, but I didn't find how to write this. myMethod( byte[] ) I just want something like anyByteArray(), how to do that with Mockito ?I would try any(byte[].class)