Questions tagged [easymock]

Easymock is a mocking framework for Java.

Easymock is an open source mocking framework for Java. It is used for creating mock objects and stubs for unit tests.

999 questions
5
votes
2 answers

Can i mock static method whith juni5 and mockito or easymock?

I need to mock a static method with junit5 (that's is very important) and mockito or easymock. I saw that powermock works only with junit 4. there exists any form to do it with junit5?
bbasstyle
  • 53
  • 1
  • 4
5
votes
2 answers

Mocking Clojure protocols

Can one of the popular Java mocking frameworks like EasyMock or Mockito be used to mock Clojure protocols defined with defprotocol? If so, how?
Ralph
  • 31,584
  • 38
  • 145
  • 282
5
votes
2 answers

EasyMock Unexpected method call expected: 1, actual: 2 java.lang.AssertionError:

Trying to test a method which takes a list of objects and returns a sorted list of objects. Sorting happens on the basis of putting the first element on the list with empty string value. The test fails with the following…
PineCone
  • 2,193
  • 12
  • 37
  • 78
5
votes
2 answers

does easymock depend on net/sf/cglib/proxy/Enhancer?

I am trying to complete a tutorial about easymock to use it for the first time. http://www.vogella.de/articles/EasyMock/article.html I am using - Eclipse IDE for Java Developers ( Build id: 20100218-1602) - Junit 4 plugin - easymock…
Dave
  • 4,184
  • 8
  • 40
  • 46
5
votes
0 answers

EasyMock unable to mock close() method on java.sql.Connection object

I'm unable to mock the close() method on java.sql.Connection object. My ultimate goal is to do connection pooling while running JUnit tests. This will eliminate connection overhead during unit testing as the code under test executes connect/close…
Ian Govett
  • 51
  • 6
5
votes
1 answer

java.lang.ExceptionInInitializerError when mocking static method using EasyMock+PowerMock

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 is purely due to my code files and the error is…
Siddharth
  • 83
  • 1
  • 1
  • 4
5
votes
1 answer

PowerMock not able to resolve ambiguous reference

I am trying to test a simple application in Scala , and test it with PowerMock. Below is my code Service.scala trait Service { def getName(): String def start(): Int } ServiceListener.scala trait ServiceListener { def onSuccess(service:…
Stacker1234
  • 187
  • 1
  • 2
  • 12
5
votes
2 answers

How to mock DynamoDB's ItemCollection using EasyMock?

I have the following Java code: Index userNameIndex = userTable.getIndex("userNameIndex"); ItemCollection userItems = userNameIndex.query("userName", userName); for (Item userItem : userItems) { } I am trying to write a unit test and…
Max
  • 15,157
  • 17
  • 82
  • 127
5
votes
2 answers

Why do I have to extend PowerMockTestCase?

The below test throws java.lang.IllegalStateException: no last call on a mock available when I don't extend from the PowerMockTestCase. The error disappears as soon as I extend from PowerMockTestCase. Why exactly is this happening? import static…
Ajay
  • 2,976
  • 2
  • 28
  • 35
5
votes
1 answer

Can EasyMock support multiple overloaded methods being added to createMockBuilder

I am working with existing test cases that use EasyMock to mock a class. I overloaded a no-parameter method so that now a method exists to take a string. For example: public class HelloClass { // This method always existed. public String…
whyceewhite
  • 6,317
  • 7
  • 43
  • 51
5
votes
1 answer

Differences between EasyMock and Mockito

I'm learning testing with EasyMock and Mockito. What are differences between them? What are advantages and disadvantages of any of them? Which one is better to use?
user1736332
  • 693
  • 4
  • 11
  • 22
5
votes
3 answers

Is it possible to mock a single method in an already existing object?

For an integration test, I need to mock a specific method in a java service client without destroying the rest of the information in it. It has no self-constructor, so a solution like this is out of the question: private DBClient mockClient = new…
AdamSpurgin
  • 951
  • 2
  • 8
  • 28
5
votes
1 answer

how to mock a method in an object when testing a method in the same object

i have such java codes: public class A { public int get() { // many codes String s = new String(); //... int n = 5; return isEmpty(s) ? n : -1; } public boolean isEmpty(String s) { return…
celix
  • 63
  • 2
5
votes
3 answers

Error received using easymock

I am working on a new project and they have been using EasyMock (v2.4), which I am not as familiar with. I need to be able to do the following, but no one has an answer. The current framework uses an BaseDao.class which I would like to mock out per…
jtoepfer
  • 315
  • 1
  • 2
  • 15
5
votes
2 answers

Unit Testing with Complicated Parameters

Lets say I have a method: someMethod(X anObject) Where X is a type of object that is extremely complex. By this I mean it is not something one can easily instantiate on the fly. I need to somehow unit test someMethod, but I cannot so simply create…
KWJ2104
  • 1,959
  • 6
  • 38
  • 53