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

EasyMock - Random tests failing - Matcher Expected

I have a strange problem with EasyMock This is the call I'm making which throws an IllegalStateException : Matcher expected as expected expect(this.mock.expectedOperation(gt(0l), MyClass.class)).andReturn(createClassObject()); If I replace the…
Varun Achar
  • 14,781
  • 7
  • 57
  • 74
0
votes
1 answer

Does EasyMock do a object injection to JUnit code?

I'm new to both JUnit and for EasyMock. I need to inject few of the classes into my JUnit test. private static TheManager theManager; public static void setUpBeforeClass() throws Exception { theManager =…
dinesh707
  • 12,106
  • 22
  • 84
  • 134
0
votes
1 answer

Mocking Classes for QFTest

At my company we are trying to make tests for a GUI build on JAVA swing using an automation tool called QFTEST. In order to get better code coverage we came to the conclusion that a mocking specific classes is necessary. My boss has directed me to…
whomaniac
  • 1,258
  • 4
  • 15
  • 22
0
votes
1 answer

EasyMock verify method called and execute method

I have a method returning void and I know how to verify if the method has been called: MyValidator validator = createMock(MyValidator.class); expect(validator.validate()); replay(validator); classUnderTest.submit(); //this will call…
user1414745
  • 1,317
  • 6
  • 25
  • 45
0
votes
2 answers

Methods calling other methods in the same class: bad design?

EasyMock 3.0 documentation (http://www.easymock.org/EasyMock3_0_Documentation.html) claims that it is, but doesn't explain why (emphasis mine): Sometimes you may need to mock only some methods of a class and keep the normal behavior of others.…
Asker
  • 105
  • 8
0
votes
1 answer

How to mock third party API via EasyMock?

How to mock third party API via EasyMock ? Ex: 2 classes - Employee - our class, NPECustomer - Third Party class Assume Employee has createCustomer method with the following code createCustomer(Employee emp) { NPECustomer customer = new…
Kathir
  • 2,733
  • 12
  • 39
  • 67
0
votes
1 answer

EasyMock how to set states of service-updated instance?

I have a client class that looks like the following: class MyClient{ Service service; public MyClient(Service service){ ... } public boolean CoreFunction(Object arg1, Object arg2){ Service.AnotherClass instance = new…
Steve
  • 4,935
  • 11
  • 56
  • 83
0
votes
0 answers

ListenableFuture behavior seems to be "broken" when executed from Powermock test

Based on guava-libraries example, I am using ListenableFuture. I am using: java 1.6 JDeveloper 11.1.1.6.0 guava-13.0.1.jar junit-4.5.jar easymock-3.1.jar powermock-easymock-1.4.12-full.jar I am trying to ensure that method under test is called in…
evgenyl
  • 7,837
  • 2
  • 27
  • 32
0
votes
1 answer

Is it possible to use andStubReturn without replay() in EasyMock

Well the question is the same as the title. Example of what I am aiming at, Order order = createNiceMock(Order.class); Products products =…
Andreas Selenwall
  • 5,705
  • 11
  • 45
  • 58
0
votes
2 answers

EasyMock aware debugger in Intellij?

Maybe this is counterproductive, I don't know, but right now I am in need of a debugger in IntelliJ that are aware of EasyMock mocks and especially what the mocks methods actually returns. For example, I have a transport interface ITransport, which…
Andreas Selenwall
  • 5,705
  • 11
  • 45
  • 58
0
votes
2 answers

Testing my UserService class, but need to mock a method that gets called at the same time

I am testing my userService classes method, but the method I am testing makes a call to another method. @Test public void testSomething() { HelloWorldResponse hwResponse = ....; expect(userDaoMock.helloWorldCall(....).andReturn(hwResponse); …
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
0
votes
2 answers

How do I ignore Eclipse errors if I include junit.jar from somewhere else?

Basically, I created a build.xml for Apache Ant. I use all the .jar files such as easymock.jar, junit.jar, which I downloaded straight from the their websites for my library (set in build.xml). When I created a new unit test file using those two…
knd
  • 1,662
  • 2
  • 15
  • 27
0
votes
1 answer

EasyMock use method

I am trying to run just a simple test using easyMock: public class Class1 implements Interface1{ public void method1(Object obj){ if(isEnable()){ doSmth(); } } public boolean isEnable(){ return isEnable; } } My…
Blanca Hdez
  • 3,513
  • 19
  • 71
  • 93
0
votes
1 answer

Mocking out a class which has some fields that are generated by random values?

I'm wondering how to make this test work! The below is the test method: As you can see the correlationId and docFamilyUUid is randomly generated by UUID class. Basically the getDocInfo first calls findAllByDocId on the mockDao and if that returns…
Phoenix
  • 8,695
  • 16
  • 55
  • 88
0
votes
2 answers

nested methods testing using easy mock

i am facing a problem regarding class mocking in java. I will explain the problem using dummy classes( to avoid project related security concerns) We have a class Employee public class Employee { public int netSalary() { int sal = totalSal() -…
Anil Sharma
  • 558
  • 6
  • 18