org.junit.Beforeorg.mockito.Mock



Project mockito/mockito in file ...mockitousage.misuse.InvalidStateDetectionTest.java (2009-04-15)
@@ -4,11 +4,12 @@
  */
 package org.mockitousage.misuse;
 
+import static org.mockito.Matchers.*;
 import static org.mockito.Mockito.*;
 
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
 import org.mockito.StateMaster;
 import org.mockito.exceptions.misusing.InvalidUseOfMatchersException;
 import org.mockito.exceptions.misusing.UnfinishedStubbingException;
@@ -38,13 +39,11 @@ import org.mockitoutil.TestBase;
 @SuppressWarnings({"unchecked", "deprecation"})
 public class InvalidStateDetectionTest extends TestBase {
 
-    private IMethods mock;
+    @Mock private IMethods mock;
 
-    @Before
     @After
     public void resetState() {
         StateMaster.reset();
-        mock = mock(IMethods.class);
     }
     
     @Test
Project mockito/mockito in file ...e6af8df/test.org.mockitousage.reset.ResetTest.java (2009-04-15)
@@ -7,20 +7,16 @@ package org.mockitousage.reset;
 import static org.mockito.Matchers.*;
 import static org.mockito.Mockito.*;
 
-import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
 import org.mockito.exceptions.misusing.MissingMethodInvocationException;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
 public class ResetTest extends TestBase {
 
-    private IMethods mock;
-
-    @Before
-    public void setup() {
-        mock = mock(IMethods.class);
-    }
+    @Mock private IMethods mock;
+    @Mock private IMethods mockTwo;
 
     @Test
     public void shouldClearArgumentMatcherStackSoAbuseOfArgumentMatchersIsNotDetectedAfterReset() {
@@ -88,4 +84,12 @@ public class ResetTest extends TestBase {
         assertContains("Mock for IMethods", "" + mockTwo);
         assertEquals("mockie", "" + mock);
     }
+    
+    @Test
+    public void shouldResetMultipleMocks() {
+        mock.simpleMethod();
+        mockTwo.simpleMethod();
+        reset(mock, mockTwo);
+        verifyNoMoreInteractions(mock, mockTwo);
+    }
 }
\ No newline at end of file
Project mockito/mockito in file ...ockitousage.matchers.InvalidUseOfMatchersTest.java (2009-04-15)
@@ -7,9 +7,9 @@ package org.mockitousage.matchers;
 import static org.mockito.Matchers.*;
 
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.mockito.AdditionalMatchers;
+import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.StateMaster;
 import org.mockito.exceptions.misusing.InvalidUseOfMatchersException;
@@ -18,13 +18,7 @@ import org.mockitoutil.TestBase;
 
 public class InvalidUseOfMatchersTest extends TestBase {
 
-    private IMethods mock;
-
-    @Before
-    public void setUp() {
-        StateMaster.reset();
-        mock = Mockito.mock(IMethods.class);
-    }
+    @Mock private IMethods mock;
 
     @After
     public void resetState() {
Project mockito/mockito in file ...test.org.mockitousage.misuse.InvalidUsageTest.java (2009-04-15)
@@ -7,9 +7,9 @@ package org.mockitousage.misuse;
 import static org.mockito.Mockito.*;
 
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.mockito.InOrder;
+import org.mockito.Mock;
 import org.mockito.StateMaster;
 import org.mockito.exceptions.base.MockitoException;
 import org.mockito.exceptions.misusing.MissingMethodInvocationException;
@@ -18,15 +18,9 @@ import org.mockitoutil.TestBase;
 
 public class InvalidUsageTest extends TestBase {
 
-    private IMethods mock;
-    private IMethods mockTwo;
+    @Mock private IMethods mock;
+    @Mock private IMethods mockTwo;
 
-    @Before
-    public void setup() {
-        mock = mock(IMethods.class);
-        mockTwo = mock(IMethods.class);
-    }
-    
     @After
     public void resetState() {
         StateMaster.reset();
Project mockito/mockito in file ...e.stacktrace.ModellingDescriptiveMessagesTest.java (2009-04-05)
@@ -6,22 +6,22 @@ package org.mockitousage.stacktrace;
 
 import static org.mockito.Mockito.*;
 
-import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.InOrder;
-import org.mockito.Mockito;
+import org.mockito.Mock;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
 @Ignore
 public class ModellingDescriptiveMessagesTest extends TestBase {
     
-    private IMethods mock;
+    @Mock private IMethods mock;
 
-    @Before
-    public void setup() {
-        mock = Mockito.mock(IMethods.class);
+    @Test
+    public void shouldSayWantedButNotInvoked() {
+        mock.simpleMethod();
+        verify(mock).otherMethod();
     }
     
     @Test
@@ -109,4 +109,18 @@ public class ModellingDescriptiveMessagesTest extends TestBase {
         
         m.simpleMethod();
     }
+    
+    @Test
+    public void shouldPointOutUnfinishedStubbing() {
+        when(mock.simpleMethod());
+        
+        verify(mock).simpleMethod();
+    }    
+
+    @Test
+    public void shouldPointOutUnfinishedStubbingWhenVoidMethodCalled() {
+        doReturn("asdf");
+        
+        verify(mock).simpleMethod();
+    }    
 }
\ No newline at end of file