Last change
on this file since 958 was 785, checked in by wouter, 9 months ago |
#275 NASTY string based python code manipulation to get proper translation of "when()"
|
File size:
865 bytes
|
Line | |
---|
1 | package testcode;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 | import static org.mockito.Mockito.mock;
|
---|
5 | import static org.mockito.Mockito.when;
|
---|
6 |
|
---|
7 | import org.junit.Test;
|
---|
8 |
|
---|
9 | class TestClass {
|
---|
10 | public int f(int x) {
|
---|
11 | return x + 1;
|
---|
12 | }
|
---|
13 | }
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Test for mockito translator. This program is going to be translated and run
|
---|
17 | * in python.
|
---|
18 | */
|
---|
19 | public class MockitoBasicTest {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * NOTE NO CONSTRUCTOR. This is needed to check that the proper constructor,
|
---|
23 | * matching in this case the implicit superclass TestCase from Python, is
|
---|
24 | * created. This is a special case, in normal cases java already enforces
|
---|
25 | * all required code including the call to super().
|
---|
26 | */
|
---|
27 |
|
---|
28 | @Test
|
---|
29 | public void testStub1() {
|
---|
30 | TestClass test = mock(TestClass.class);
|
---|
31 | when(test.f(3)).thenReturn(1);
|
---|
32 | // the mock did not do any when.thenReturn and should fail
|
---|
33 | assertEquals(1, test.f(3));
|
---|
34 |
|
---|
35 | }
|
---|
36 |
|
---|
37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.