jmockit

Using JMockit to mock autowired interface implementations

We are writing JUnit tests for a class that uses Spring autowiring to inject a dependency which is some instance of an interface. Since the class under test never explicitly instantiates the dependency or has it passed in a constructor, it appears that JMockit doesn't feel obligated to instantiate it either. Up until now we have been us...

NullPointerException Using JMockit to Test Mocked java.io.File Twice

I'm getting a NullPointerException when I try to use a mocked File with JMockit: package com.metamolecular.poobah.test; import java.io.File; import junit.framework.TestCase; import mockit.Expectations; import mockit.Mocked; public class MockedFileTest extends TestCase { @Mocked File file; public void testMockedFileCanBeUsed1() thr...

Regarding JMOCKIT

Hi All, I am new to JMockit.Among the three JMockit Annotations,Jmockit Expectations or JMockit Core api Which one is best to write jmockit test cases. I have to write the test cases for the Portal Applications where we are using JPF Controllers.Can anyone help me on how to write Test Cases for the page flow controllers. Regards,Viks ...

Jmockit expectations error

I have unit test case where I am using JMockit with expectations. Now when I run the test case alone, the test case passes. But when I run all test cases collectively, I get the: expected exactly 1 time, already invoked... error. I feel that some configuration or states set in jmock by previous test cases has not cleared. Has anyone...

Combine jmockit & jbehave

I found jmockit a great mocking framework and jbehave a great way doing software testing. However, I'm unable to coordinate the two. In order to run jbehave in eclipse, I create a class that extends the JUnitScenario. This class in turn use a Steps class. And I place several mocks inside this Steps class. However, when being executed, J...

JMockit - initialization problem

When I use the following test I get a WARNING: WARNING: JMockit was initialized on demand, which may cause certain tests to fail; please check the documentation for better ways to get it initialized. This is my test implemenation: package test; import static mockit.Mockit.*; import junit.framework.TestCase; import mockit.*; imp...

Jmockit in JBoss

In a jboss service I need to mock some inner class (not EJB) with JMockit. Just for tests I've created inner class ToBeMocked and another one Mock. While deploying to jboss I get error NoClassDefFoundError in line: Mockit.setUpMock(ToBeMocked.class, new Mock()); with message: java.lang.NoClassDefFoundError: mockit/Mockit jmockit.ja...

JMockit returns collection

I have the following code: public void someMethod() { Set<Foo> fooSet = bar.getFoos(); for(Foo foo: fooSet) { foo.doSomething(); } } and I want to test this using JMockit but am unsure how to get to return a collection of a certain type and size. The following test for my code throws a null pointer exception ...

Does JMockit have any drawbacks at all?

This comparison shows, that JMockit has several advantages over other frameworks. Are there also any advantages that one of the others (JMock, EasyMock, Mockito, Unitils, PowerMock + Mockito/EasyMock) has over JMockit? ...

Can I use Cactus and JMockIT together and JMockIT error

I have integrated JMockIT and Cactus in my application and when I am testing my application I am mocking my method behaviour in cactus test classes. But It is giving me following error when I try to execute my test case java.lang.RuntimeException: Failed to read class file for com.test.app.int.allite.action.junit.MockedClass ...

JMockit Troubles (just starting)

SO I have a kinda convoluted problem I will describe it with similar examples instead of copying TONS of code in. The problem comes in that I don't really know how to use JMockit well, dare I say properly. I have an interface: public interface IRsrcResolver { RsrcSet getForQuery(Query, RsrcContext, int); } There is a real implement...