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
0
votes
1 answer

Spring-WS 2.0 unit testing without a running backend

I would like to be able to do some unit testing during development in order to catch potential errors when extending/changing the way a given web service (endpoint) works. I have been looking at EasyMock, and this seems like a viable way to go -…
sunlock
  • 212
  • 5
  • 17
-1
votes
2 answers

How do I mock a Scala Companion Object with EASYMOCK on Scala 3?

I have the following code... class CoreDataSource { def getConnection = { println("Getting the connection") CoreDataSource.getConnection } } object CoreDataSource { def getConnection: Option[Connection]…
Jackie
  • 21,969
  • 32
  • 147
  • 289
-1
votes
1 answer

I am getting missing behaviour definition for the preceding method call:

I am new to unit test. I am trying to create test case of a method which is calling an static method. For this static method I am getting "getting missing behaviour definition for the preceding method call:"
-1
votes
1 answer

NoClassDefFoundError when using @RunWith(PowerMockRunner.class)

I am running a junit test case using the PowerMock test runner. When I'm running the class, I'm receiving this error: java.lang.NoClassDefFoundError: org/powermock/tests/utils/TestSuiteChunker Caused by: java.lang.ClassNotFoundException:…
karthick S
  • 51
  • 1
  • 2
  • 9
-1
votes
2 answers

junits failing with easymock

I am using EasyMock to write unit tests for my blackjack game. But I get java.lang.IllegalArgumentException: Cannot subclass final class class com.blackjack.game.cards.Card error. Although, I feel I am doing it the right way. Here is my testclass…
AYa
  • 421
  • 3
  • 9
  • 21
-1
votes
1 answer

How to mock Instance DAO methods using PowerMock+EasyMock+Junit+Java

I am new to Unit Testing, got some requirement to mock DAO layer but not getting how to do it. Below is my sample DAO code which is doing some transactional activities. Class DAOList{ public Object getRows(Map mapObj, Object error) { Session…
Vishwas Sampath
  • 113
  • 1
  • 2
  • 8
-1
votes
1 answer

Unit testing when part of the class needs to be mocked

I have a class that I am trying to unit test. This class extends another class that I am not interested in unit testing at this time. The following code is an over simplification of the code I am trying to test. package…
buzzsawddog
  • 662
  • 11
  • 32
-1
votes
1 answer

easy mock's expect method gives test result passed at even false tests

I am using easymock to test my class. After writing codes, I find out that every test succeeds even given wrong inputs. From the forums on stack overflow, I have seen that it could be avoided by using the replay method but it even succeeds when I…
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63
-1
votes
2 answers

Is it possible to test static functions by easyMock

I want to check if it returns with same value by using EasyMock's andReturn method. Unfortunately, I come across with "java.lang.IllegalStateException: missing behavior definition for the preceding method call:" when I use EasyMock. I guess it is…
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63
-1
votes
1 answer

Specifying the number of times to return object in a chained AndReturn expression with multiple return objects

I have a mock, for which I expect object1 for 1st call and object2 for next 2 calls. Is this expression correct? EasyMock.expect(result.get(0)).andReturn(object1).andReturn(object2).times(2); or should I use…
goelakash
  • 2,502
  • 4
  • 40
  • 56
-1
votes
1 answer

How to mock an interface implementation inside a method?

I have a method that will call a service with a Callable implementation. However, I have no idea how to mock this implementation in my test code because the Callable is implemented with lambda expression on the fly. Is there any way i can achieve…
-1
votes
1 answer

Mocking a Void method

This is my first attempt at using EasyMock. So, I've been trying to mock a void method: protected void onStop() { logger.info("Stopping ReporterService."); if (reporter != null) { reporter.stop(); reporter = null; } } I…
Alex Bloomberg
  • 855
  • 1
  • 7
  • 14
-1
votes
1 answer

EasyMock - CreateNiceMock

A fairly straightforward question regarding EasyMock. Read up a bunch of resources but not sure what I am missing: The following snippet is creating a unit test using Test-ng: @Test(groups = "unit") public class SchoolTestEasyMock { @Test …
vksinghh
  • 223
  • 4
  • 16
-1
votes
1 answer

How to test this method by JUnit & EasyMock?

I have a @Component public class MyBean{ @Autowired Bean1 bean1; @Autowired Bean2 bean2; public void create(Param param1, Param param2){ SomeObject object = bean2.getDesiredResult(); …
Farhan stands with Palestine
  • 13,890
  • 13
  • 58
  • 105
-1
votes
1 answer

EasyMock expect(anyObject, anyObject).andReturn(myObject) gives "2 matchers expected, 3 recorded"?

My code looks like Request1 req1 = EasyMock.anyObject(Request1.class); Request2 req2 = EasyMock.anyObject(Request2.class); Request3 req3 = EasyMock.anyObject(Request3.class); @Mock Service service; // ... @Test myTest() { Response resp = new…
djechlin
  • 59,258
  • 35
  • 162
  • 290
1 2 3
66
67