Questions tagged [jmock]

For questions about using jMock. JMock is a helper framework for test-driven development and unit testing.

According to the jMock project website,

JMock is a library that supports test-driven development of Java code with mock objects.

Mock objects help you design and test the interactions between the objects in your programs.

The jMock library:

  • makes it quick and easy to define mock objects, so you don't break the rhythm of programming
  • lets you precisely specify the interactions between your objects, reducing the brittleness of your tests
  • works well with the autocompletion and refactoring features of your IDE
  • plugs into your favourite test framework
  • is easy to extend
257 questions
0
votes
1 answer

How to mock 2 or multiple prepared statements per connection in jMock?

public void testCreate() throws ApplicationException { DutyDrawback drawback = new DutyDrawback(); drawback.setSerialNumber("TEST123"); drawback.setSnProcessInd("Y"); drawback.setMediaNumber("TEST111"); …
axiomtheorem
  • 151
  • 3
  • 20
0
votes
1 answer

How to JMock a Singleton

My application has this structure: there's a RepositoryFacade (that is a Singleton) that uses many other ObjectRepository that are Singleton (UserRepository, etc). Now I'd like to test it, mocking the [Objetct]Repositiries. To do that I made the…
andreaxi
  • 931
  • 5
  • 15
  • 28
0
votes
2 answers

How to test a void method with JMock

How to test a void method i.e. method that doesn't return anything in JMock?
Anand
  • 20,708
  • 48
  • 131
  • 198
0
votes
1 answer

spring junit testing with JMock

I have a Spring maven project and we are going to use JMock to test service/business/DAO layers of my project as suggested by client. Can somebody please provide me the good link going through which I can understand and implement it? Also I have…
Anand
  • 20,708
  • 48
  • 131
  • 198
0
votes
1 answer

How do I use states in jmock?

I'm writing an integration test that simulates a sequence of actions coming from the front end. I'm setting up my expectations like this: context.checking(new Expectations() {{ States state = states("service"); …
Kevin Peterson
  • 7,189
  • 5
  • 36
  • 43
0
votes
1 answer

JMock strange try/catch clause

I am trying to write up a few tests using JMock and the following code will be added: db = context.mock(DBResultQueryExecutor.class); context.checking(new Expectations() {{ oneOf (db).prepareQuery(query); will(throwException(new…
Bober02
  • 15,034
  • 31
  • 92
  • 178
0
votes
1 answer

Setting up a Mockery's Expectations in relation to protected methods

I'm running into a problem with trying to set up a Mockery to test for method invocation. I saw How to test protected methods of abstract class using JUnit and JMock and it's essentially the same question, but I can't make out what Chris is…
Joishi Bodio
  • 438
  • 6
  • 17
0
votes
3 answers

What makes up the "standard jmock libraries"?

I'm following this guide http://javaeenotes.blogspot.com/2011/06/short-introduction-to-jmock.html I've received the error java.lang.SecurityException: class "org.hamcrest.TypeSafeMatcher"'s signer information does not match signer information of…
Eric Francis
  • 23,039
  • 31
  • 88
  • 122
0
votes
1 answer

Jmock match string parameter exactly

I read from Jmock's homepage about matchers, and at the very top there was an example about string matchers. I didn't understand because, according to the example, matching a string would be as easy as writing import static org.hamcrest.Matchers.*;…
Adam Miller
  • 1,756
  • 1
  • 25
  • 44
0
votes
1 answer

JMock - how to mock console output

This post is similar to: this I have a console app that expects both user input and has responsive user output. I am writing some unit tests for it to make sure that the code works properly. I need to be able to make sure that the output and input…
Adam Miller
  • 1,756
  • 1
  • 25
  • 44
0
votes
3 answers

Jmock - how to automate & mock out console user input?

I have some functionality that I want to mock out being called from main (static: I've read about that too - jmock mocking a static method). i recently read that JMock doesn't support the mocking of static functions. Well, the associated code…
Adam Miller
  • 1,756
  • 1
  • 25
  • 44
0
votes
1 answer

What is the purpose of Imposteriser?

I'm following this tutorial: http://jeantessier.com/SoftwareEngineering/Mocking.html#jMock I am trying to mock a class. I don't understand what the Imposteriser does? http://www.jmock.org/javadoc/2.5.1/org/jmock/api/Imposteriser.html Thanks
Eric Francis
  • 23,039
  • 31
  • 88
  • 122
0
votes
1 answer

jmock-2.5.1.jar vs jmock-junit3-2.5.1.jar

What is the difference between the jars jmock-2.5.1.jar and jmock-junit3-2.5.1.jar? Does jmock-junit contain both frameworks? Thanks
Eric Francis
  • 23,039
  • 31
  • 88
  • 122
0
votes
1 answer

JMock tutorial using JUnit 3?

I'm looking for a JMock tutorial using JUnit 3. Preferably an easy one as well. Every JMock tutorial I have found has been fairly difficult to read through. Also, is it worth it to use JUnit 4? Thanks
Eric Francis
  • 23,039
  • 31
  • 88
  • 122
0
votes
1 answer

Saving return value of a Expectation

I want to use return vale of a expectation to add to one more expection. I have a m_accountProcessor object which has interface createAccount to create a new account and returns a Account object. I want to save this object and add it to one more…
Sirish
  • 9,183
  • 22
  • 72
  • 107
1 2 3
17
18