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
4
votes
3 answers

java.lang.NoSuchMethodError powermock

Guys Question: How to mock a static final class which has defined some other static final class? Problem Description: When I want to write some unit test case for a final class ApplianceRelationshipUtils.java, and in this final class…
Leeric
  • 41
  • 1
  • 1
  • 2
4
votes
2 answers

Jmock - How to mock a static method

Possible Duplicate: jmock mocking a static method I am working on a legacy unit test which uses static methods of a class XX. I have now changed the class to get a field value from Spring application context. The unit test now fail as the class…
maverik
  • 3,409
  • 3
  • 16
  • 7
3
votes
4 answers

Testing a concrete third-party class with JMock

I have class with a forwarding method foo: void foo( Concrete c, String s ) { c.bar( s ); } I wish to test whether foo does, in fact, forward. Unfortunately for me, Concrete is a class in a third-party library, and is a concrete type, not an…
tpdi
  • 34,554
  • 11
  • 80
  • 120
3
votes
1 answer

How to test that all methods of a class is not called in jMock?

Using jMock, how do I test that all methods of a certain class is not called upon invoking a method in another class? For example, if I have class A and class B: class A { void x() { } void y() { } void z() { } } class B { …
krismath
  • 1,879
  • 2
  • 23
  • 41
3
votes
1 answer

Is there a way to include two versions of the same artifact in Maven?

org.jmock jmock 1.2.0
DD.
  • 21,498
  • 52
  • 157
  • 246
3
votes
6 answers

Bringing unit testing to an existing project

I'm working on an existing Java EE project with various maven modules that are developed in Eclipse, bundled together and deployed on JBoss using Java 1.6. I have the opportunity to prepare any framework and document how unit testing should be…
rich
  • 18,987
  • 11
  • 75
  • 101
3
votes
2 answers

NetBeans Platform Unit Test Library Dependencies

I am working on a Netbeans Platform RCP application. I use jmock in my unit tests and I have created a Library Wrapper Module to import the necessary libraries. The Module has an section named 'Libraries' and another section named 'Unit Test…
Ben Hammond
  • 705
  • 1
  • 7
  • 20
3
votes
2 answers

Cactus versus mock objects (jMock, Easy mock)

I'm little confused with Cactus and mock objects (jMock, Easy mock). Could anyone please answer the following questions? When to use Cactus for testing? When not to use Cactus for testing? When to use mock objects for testing? When not to use mock…
Isabel Jinson
  • 8,541
  • 16
  • 59
  • 75
3
votes
1 answer

jdave-unfinalizer Java 7 stackmap frame

I'm using JMock & JDave unfinalizer, it was fine with Java 6. but after moving to Java 7 my unit tests that use jdave-unfinalizer fail with such error: java.lang.VerifyError: Expecting a stackmap frame at branch target 49 Exception Details: …
Anton
  • 41
  • 3
3
votes
1 answer

JUnit, JMock, JUnitRuleMockery: what am I missing

This is strange: I am using JUnit with JMock using the Rule JUnitRuleMockery for a while and it always worked perfectly fine: expectations where checked at the end of the test and if one (or more) was missing the test was failing. However, this…
ThanksForAllTheFish
  • 7,101
  • 5
  • 35
  • 54
3
votes
1 answer

maven - How to solve this error : "The POM for XXX is invalid"?

I'm building a simple project with maven. I'm unable to get it to build because a transitive dependencies is missing, namely objenesis 1.0. I run maven in debug mode and got this message: [DEBUG]…
Stephan
  • 41,764
  • 65
  • 238
  • 329
3
votes
1 answer

AtUnit vs 'Junit,JMock and GUICE' by hand -?

How does AtUnit fare with respect to unit testing using DI and guice ?. Please share your experiences.
varuntayur
  • 31
  • 2
3
votes
1 answer

JMock "unexpected invocation" when the same invocation is "expected once, never called"

I changed some method somewhere in our code which shouldn't have caused any weird test failures, but JMock seems to think otherwise. I boiled the issue down to the minimal amount of cruft, which looks something like this: import…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
3
votes
2 answers

JMock expectation IllegalArgumentException

I am trying to use the allowing method to fix the return value of a method on one of my mocked objects. I have the following method on a mocked object jdbc which I want to allow for: List query(String sql, RowMapper rowMapper) I am using…
The Cat
  • 2,375
  • 6
  • 25
  • 37
3
votes
1 answer

Using JMock2 with Matchers in Groovy: problems with 'with' method

I have a following snippet with JMock expectations in my test method: context.checking(new Expectations() {{ allowing(listener).tableChanged(with(anyInsertionEvent())); oneOf(listener).tableChanged(with(aRowChangedEvent(0))); }}); where…
Rorick
  • 8,857
  • 3
  • 32
  • 37