1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage; 6 7 import org.junit.Test; 8 import org.mockito.Mock; 9 import org.mockitoutil.TestBase; 10 11 public class PlaygroundTest extends TestBase { 12 static class Foo { 13 doSomeThing()14 int doSomeThing() { 15 return 0; 16 } 17 getStuff()18 protected String getStuff() { 19 return "foo"; 20 } 21 } 22 23 class Boo { withLong(long y)24 public final Object withLong(long y) { 25 return ""; 26 } 27 foo()28 public Object foo() { 29 return ""; 30 } 31 } 32 33 Foo mock; 34 @Mock IMethods mockTwo; 35 36 @Test spyInAction()37 public void spyInAction() {} 38 39 @Test partialMockInAction()40 public void partialMockInAction() { 41 // mock = mock(Foo.class, withSettings() 42 // .defaultBehavior(CALLS_REAL_METHODS); 43 44 // mock = mock(Foo.class, withSettings() 45 // .defaultMockAnswer(CALLS_REAL_METHODS); 46 47 // mock = mock(Foo.class, withSettings() 48 // .defaultAnswer(CALLS_REAL_METHODS); 49 50 // mock = mock(Foo.class, CALLS_REAL_METHODS); 51 52 // mock = mock(Foo.class, withSettings() 53 // .defaultBehavior(CALLS_REAL_METHODS) 54 // .createUsingDefaultConstructor(); 55 // 56 // mock = mock(Foo.class, withSettings() 57 // .defaultBehavior(CALLS_REAL_METHODS) 58 // .createPassingArguments("some arg", 1); 59 // 60 // spy = spy(Foo.class, "some arg", 1); 61 // 62 // .withName("foo") 63 // .withDefaultBehavior(RETURNS_SMART_NULLS) 64 // .withInterfaces(Bar.class); 65 // 66 // mock = mock(Foo.class) 67 // .name("foo") 68 // .defaultBehavior(RETURNS_SMART_NULLS) 69 // .interfaces(Bar.class); 70 // 71 // mock = mock(Foo.class) 72 // .named("foo") 73 // .byDefault(RETURNS_SMART_NULLS) 74 // .alsoImplements(Bar.class, Bar2.class); 75 // 76 // mock = mock(Foo.class) 77 // hasName("foo"); 78 79 // when(mock.getStuff()).thenReturn("aha!"); 80 // when(mock.doSomeThing()).thenCallRealMethod(); 81 // 82 83 // mock.doSomeThing(); 84 } 85 86 // interface Colored { 87 // 88 // } 89 // 90 // interface Bar { 91 // <T extends Foo & Colored> T getColoredPoint(); 92 // } 93 // 94 // @Test 95 // public void testname() throws Exception { 96 // when(mock.get()).then(returnArgument()); 97 // 98 // Bar mock = mock(Bar.class); 99 // when(mock.getColoredPoint()).thenReturn(new Foo()); 100 // } 101 } 102