source: java2python/mockito-t/test/testcode/MockitoBasicTest.java@ 874

Last change on this file since 874 was 785, checked in by wouter, 10 months ago

#275 NASTY string based python code manipulation to get proper translation of "when()"

File size: 865 bytes
RevLine 
[785]1package testcode;
2
3import static org.junit.Assert.assertEquals;
4import static org.mockito.Mockito.mock;
5import static org.mockito.Mockito.when;
6
7import org.junit.Test;
8
9class 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 */
19public 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.