Skip to content
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
d2ec1e5
Add new module for mocks comparison.
varomorf Jun 4, 2016
49b5413
Add sources for testing.
varomorf Jun 4, 2016
3b04641
Changes on testCase.
varomorf Jun 4, 2016
b6fdbcc
Enter some tests for mockito.
varomorf Jun 4, 2016
9fd7aa4
More tests for Mockito.
varomorf Jun 5, 2016
915bc6b
Even more tests.
varomorf Jun 5, 2016
59162e4
Add the rest of the mocking libraries.
varomorf Jun 5, 2016
3ef9946
Javadoc on test.
varomorf Jun 12, 2016
5aa5b57
Test bare bones for EasyMock.
varomorf Jun 12, 2016
af05a28
Fist kind of test and setup.
varomorf Jun 12, 2016
0bd3074
Add tests using EasyMock with a change on LoginService.
varomorf Jun 12, 2016
125f7d6
Create LoginControllerTest.java
varomorf Jun 14, 2016
d5e0690
Test setup
varomorf Jun 14, 2016
84ef411
[JMockit] No method called test.
varomorf Jun 14, 2016
e632bf5
[JMockit] Two methods called test.
varomorf Jun 14, 2016
e00e4e1
[JMockit] One method called test.
varomorf Jun 14, 2016
2a30ed7
[JMockit] Exception mock test
varomorf Jun 14, 2016
9cd0d02
[JMockit] Mocked object to pass around test.
varomorf Jun 14, 2016
9e24141
[JMockit] Custom matcher test.
varomorf Jun 14, 2016
48925b1
[JMockit] Partial mocking test.
varomorf Jun 14, 2016
4d17086
[JMockit] Fix with IDE.
varomorf Jun 14, 2016
1e90607
Merge remote-tracking branch 'upstream/master'
varomorf Jun 15, 2016
92bb44e
Not stubs. Mocks. MOCKS!!!
varomorf Jun 17, 2016
4136736
Merge remote-tracking branch 'upstream/master'
varomorf Jun 17, 2016
b1a1e9e
Remove unnecesary import.
varomorf Jun 18, 2016
aa25432
Merge remote-tracking branch 'upstream/master'
varomorf Jun 18, 2016
9dfe61b
Merge remote-tracking branch 'upstream/master'
varomorf Jun 24, 2016
517eef2
Use correct encoding. Was having problems with buildings.
varomorf Jul 3, 2016
6fa3670
Remove failing module.
varomorf Jul 3, 2016
f083e31
Create new module mocks and move mock-comparisons there.
varomorf Jul 3, 2016
eb31bba
Add jmockit module.
varomorf Jul 3, 2016
5dde0ed
Add model class.
varomorf Jul 3, 2016
11b8497
Add collaborator class.
varomorf Jul 3, 2016
b16d4b2
Add performer class.
varomorf Jul 3, 2016
9277aa8
Add performer test.
varomorf Jul 3, 2016
fe28c33
Merge remote-tracking branch 'upstream/master'
varomorf Jul 3, 2016
0dccd9c
Merge remote-tracking branch 'upstream/master'
varomorf Jul 5, 2016
6fff1c0
Fix
varomorf Jul 6, 2016
707f4ab
Merge remote-tracking branch 'upstream/master'
varomorf Jul 10, 2016
cd72e4e
Merge remote-tracking branch 'upstream/master'
varomorf Jul 17, 2016
149b36c
Add interface for tests.
varomorf Jul 17, 2016
cf1c515
Test for any.
varomorf Jul 17, 2016
815dbec
Test for with.
varomorf Jul 17, 2016
1a2c924
Test for null.
varomorf Jul 17, 2016
972caca
Test for times.
varomorf Jul 17, 2016
23eea1c
Test for arg that.
varomorf Jul 17, 2016
80c2a0b
Test for result and returns.
varomorf Jul 17, 2016
df72be7
Test for delegate.
varomorf Jul 17, 2016
9301506
Merge remote-tracking branch 'origin/master'
varomorf Jul 17, 2016
60dda57
Add verifications to any tests.
varomorf Jul 20, 2016
8da0f90
Add verifications to with test.
varomorf Jul 20, 2016
287ae6e
Add verification examples to methods using null.
varomorf Jul 20, 2016
74a4e53
Add verifications to methods using times.
varomorf Jul 20, 2016
b77f112
Merge remote-tracking branch 'upstream/master'
varomorf Jul 20, 2016
30606d4
Formatting.
varomorf Jul 20, 2016
b3af213
Compress tests and fix one test.
varomorf Jul 20, 2016
211b429
Merge remote-tracking branch 'upstream/master'
varomorf Jul 20, 2016
663ab26
Merge remote-tracking branch 'upstream/master'
varomorf Jul 21, 2016
70ca81b
Adding new article to readme.
varomorf Jul 22, 2016
e42aa81
[BAEL-178] Add collaborator for advanced article.
varomorf Jul 30, 2016
40a8b89
[BAEL-178] Add link to readme.
varomorf Jul 30, 2016
7c0c892
[BAEL-178] Add test for mockUp.
varomorf Jul 30, 2016
8384199
[BAEL-178] Add test for invoke method.
varomorf Jul 30, 2016
8556fe5
[BAEL-178] Add constructors and tests for mockup for constructors.
varomorf Jul 30, 2016
21cfc69
[BAEL-178] Add private fields and more test for deencapsulation.
varomorf Jul 30, 2016
79dfbd8
[BAEL-178] Add inner class and test for instantiating inner classes.
varomorf Jul 30, 2016
8c2b02a
[BAEL-178] Multimocks.
varomorf Jul 31, 2016
112876b
[BAEL-178] Add test for expectation reusing.
varomorf Jul 31, 2016
77d8873
Merge remote-tracking branch 'upstream/master'
varomorf Jul 31, 2016
f532134
[BAEL-178] Move test class to tests folders.
varomorf Jul 31, 2016
6d1fc2e
Merge remote-tracking branch 'upstream/master'
varomorf Jul 31, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.baeldung.mocks.jmockit;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import mockit.Expectations;
import mockit.Injectable;
import mockit.Mocked;
import mockit.Tested;
import mockit.Verifications;
import mockit.integration.junit4.JMockit;

@RunWith(JMockit.class)
public class ReusingTest {

@Injectable
private Collaborator collaborator;

@Mocked
private Model model;

@Tested
private Performer performer;

@Before
public void setup(){
new Expectations(){{
model.getInfo(); result = "foo"; minTimes = 0;
collaborator.collaborate("foo"); result = true; minTimes = 0;
}};
}

@Test
public void testWithSetup() {
performer.perform(model);
verifyTrueCalls(1);
}

protected void verifyTrueCalls(int calls){
new Verifications(){{
collaborator.receive(true); times = calls;
}};
}

final class TrueCallsVerification extends Verifications{
public TrueCallsVerification(int calls){
collaborator.receive(true); times = calls;
}
}

@Test
public void testWithFinalClass() {
performer.perform(model);
new TrueCallsVerification(1);
}
}