Linked Questions
26 questions linked to/from What's the best mock framework for Java?
31
votes
3
answers
36k
views
What is the difference between PowerMock, EasyMock and Mockito frameworks? [duplicate]
I am very new to mocking framework, and my work needs mocking framework to finish unit testing. In the current code base i could see above 3 frameworks are being used in different places for unit ...
130
votes
5
answers
75k
views
Comparison between Mockito vs JMockit - why is Mockito voted better than JMockit? [closed]
I'm investigating which mocking framework to use for my project and have narrowed it down to JMockit and Mockito.
I notice that Mockito was voted "the best mock framework for Java" on Stackoverflow.
...
28
votes
5
answers
17k
views
How to write a jUnit test for a class that uses a network connection
I would like to know what's the best approach to test the method "pushEvent()" in the following class with a jUnit test.
My problem is, that the private method "callWebsite()" always requires a ...
19
votes
7
answers
7k
views
Unit testing in Java - what is it? [closed]
Can you explain in a few sentences:
Why we need it / why they make our life easier ?
How to unit-test [simple example in Java] ?
When do not we need them / types of projects we can leave unit-testing ...
22
votes
4
answers
10k
views
Mockito preferrable over EasyMock? [closed]
Recently I made the switch to Mockito framework and am very happy with it (see also blog-post). The switch from EasyMock to Mockito was very straightforward and I managed to make the tests down ...
11
votes
7
answers
10k
views
What are the most commonly used Java Frameworks? [closed]
for me I will answer this question based on my experience.
so if I'm gonna start new project I will use the following technologies:
AndroMDA as MDA framework.
Spring (DI, Interceptors, Quartz, ACEGI, ...
8
votes
6
answers
11k
views
How to mock object construction?
Is there a way to mock object construction using JMock in Java?
For example, if I have a method as such:
public Object createObject(String objectType) {
if(objectType.equals("Integer") {
...
9
votes
5
answers
3k
views
Integration tests of a polyglot stack (Java/MongoDB/RabbitMQ...)
I am aware RabbitMQ is written in Erlang and thus can't be embedded in a JVM like we would do with the ActiveMQ JMS broker for exemple.
But actually there are some projects that are done in another ...
4
votes
4
answers
9k
views
How to mock a sftp session
I am updating a few tests. The Before gets the sftp session. For this, the username and password have been hardcoded in the properties file. Due to security reasons, the password cannot be checked in ...
4
votes
4
answers
5k
views
Mock Object Libraries in Java
Would anyone suggest a Mock library and provide the reasoning behind the pick?
I am looking to introduce one to the existing code base.
Thanks.
2
votes
3
answers
6k
views
Best Mock object framework for EJB junit tests
Which mocking framework is preferred for testing EJB's (specifically Message Driven Beans), I'm looking at MockObjects, easyMock, MockEJB and mockito but open all.
I've not used mocking framework ...
4
votes
2
answers
5k
views
How to write unit test using mock object?
The more I read mock example, the more I get confused...
I have classA method eat() that calls FatDude class eatThemAll()
public class classA {
FatDude dude = new FatDude();
public String ...
1
vote
6
answers
5k
views
How to simulate server down/available in java?
Our application has server/client side. The client supports both offline and online work mode.
So I need to test the client when server down, regain connective.
Question comes. How to simulate server ...
2
votes
3
answers
890
views
is it practically possible to do good TDD (or BDD) without using any DI framework in java?
IMO one of the main characteristics of a good TDD is: testing your class (or actually unit) in isolation.
When you do so, you are able to actually test single behavior in each test -- only one test ...
3
votes
3
answers
4k
views
Patching Java classes with a mock implementation in a unit test
I have a class A which instantiates an object from class B internally. That second class has lots of external side-effects, e.g. it uses a network connection.
public class A {
private B b;
...