Uploaded image for project: 'Unitils'
  1. Unitils
  2. UNI-231

assertNoMoreInvocations() doesn't care for non-asserted methods

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.2
    • Fix Version/s: None
    • Component/s: mock
    • Labels:
      None
    • Environment:
      ubuntu, eclipse 3.7, TestNG

      Description

      The following test case doe not fail, but should due to the fact that method event.getInfo() was invoked but not asserted for invocation:

      public class UnitilsMockAssertNoMoreInvokationsTest extends UnitilsTestNG {
          
          Mock<MyEvent> eventMock;
          
          @Test(groups="Unit")
          public void testNoMoreInvocations() {

              // setup behavior
              Info info = new Info();
              eventMock.returns(info).getInfo();
              
              // get mock
              MyEvent event = eventMock.getMock();
              
              // call method, create scenario
              event.getInfo();
              
              // do _not_ assert invokation
              // eventMock.assertInvoked().getInfo();
              
              // does not care:
              MockUnitils.assertNoMoreInvocations();
              
          }
          
          
          class MyEvent {
              
              private Info info;
              
              public void setInfo(Info info) {
                  this.info = info;
              }

              public Info getInfo() {
                  return info;
              }
          }
          
          class Info {}
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              klaschkaf Florian Klaschka
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: