Repository: mockito/mockito
Issue: Add BDD version of verifyZeroInteractions()
Labels: enhancement
BDD

Right now my tests look like:

``` java
then(file).should().moveTo(directory);
then(log).should().warn("Moved file"));
verifyZeroInteractions(otherFile);
```

Would be great to have BDD replacement for `verifyZeroInteractions()`. Then the test would be even nicer:

``` java
then(file).should().moveTo(directory);
then(log).should().warn("Moved file"));
then(otherFile).shouldHaveZeroInteractions();
```


Issue comments:
OK, are you ready for a PR ?

@bric3, please see #221


Pull request review comments:

Patch that resolved the issue:
diff --git a/src/org/mockito/BDDMockito.java b/src/org/mockito/BDDMockito.java
index 3d008b5516..d0e280c665 100644
--- a/src/org/mockito/BDDMockito.java
+++ b/src/org/mockito/BDDMockito.java
@@ -57,6 +57,7 @@
  *   person.ride(bike);
  *
  *   then(person).should(times(2)).ride(bike);
+ *   then(police).shouldHaveZeroInteractions();
  * </code></pre>
  *
  * One of the purposes of BDDMockito is also to show how to tailor the mocking syntax to a different programming style.
@@ -229,6 +230,12 @@ public static interface Then<T> {
          * @since 1.10.5
          */
         T should(VerificationMode mode);
+
+        /**
+         * @see #verifyZeroInteractions(Object...)
+         * @since 2.0.0
+         */
+        void shouldHaveZeroInteractions();
     }
 
     static class ThenImpl<T> implements Then<T> {
@@ -254,6 +261,14 @@ public T should() {
         public T should(VerificationMode mode) {
             return verify(mock, mode);
         }
+
+        /**
+         * @see #verifyZeroInteractions(Object...)
+         * @since 2.0.0
+         */
+        public void shouldHaveZeroInteractions() {
+            verifyZeroInteractions(mock);
+        }
     }
 
     /**


Test patch:
diff --git a/test/org/mockitousage/customization/BDDMockitoTest.java b/test/org/mockitousage/customization/BDDMockitoTest.java
index 8211338b43..71b50196bc 100644
--- a/test/org/mockitousage/customization/BDDMockitoTest.java
+++ b/test/org/mockitousage/customization/BDDMockitoTest.java
@@ -7,6 +7,7 @@
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.exceptions.misusing.NotAMockException;
+import org.mockito.exceptions.verification.NoInteractionsWanted;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
@@ -222,16 +223,32 @@ public void shouldPassForExpectedBehaviorThatHappened() {
         then(mock).should().booleanObjectReturningMethod();
     }
 
+    @Test
+    public void shouldValidateThatMockDidNotHaveAnyInteractions() {
+
+        then(mock).shouldHaveZeroInteractions();
+    }
+
+    @Test(expected = NoInteractionsWanted.class)
+    public void shouldFailWhenMockHadUnwantedInteractions() {
+
+        mock.booleanObjectReturningMethod();
+
+        then(mock).shouldHaveZeroInteractions();
+    }
+
     @Test
     public void shouldPassFluentBddScenario() {
 
         Bike bike = new Bike();
         Person person = mock(Person.class);
+        Police police = mock(Police.class);
 
         person.ride(bike);
         person.ride(bike);
 
         then(person).should(times(2)).ride(bike);
+        then(police).shouldHaveZeroInteractions();
     }
 
     static class Person {
@@ -242,4 +259,8 @@ void ride(Bike bike) {}
     static class Bike {
 
     }
+
+    static class Police {
+
+    }
 }