Class MockObjectTestCase

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Mockery context  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checking​(ExpectationBuilder expectations)
      Specify expectations upon the mock objects in the test.
      Mockery context()  
      private void initialise()  
      <T> T mock​(java.lang.Class<T> typeToMock)
      Create a mock object of type T with a name derived from its type.
      <T> T mock​(java.lang.Class<T> typeToMock, java.lang.String name)
      Create a mock object of type T with an explicit name.
      Sequence sequence​(java.lang.String name)
      Returns a new sequence that is used to constrain the order in which expectations can occur.
      void setDefaultResultForType​(java.lang.Class<?> type, java.lang.Object result)
      Sets the result returned for the given type when no return value has been explicitly specified in the expectation.
      void setImposteriser​(Imposteriser imposteriser)
      Changes the imposteriser used to adapt mock objects to the mocked type.
      void setNamingScheme​(MockObjectNamingScheme namingScheme)
      Changes the naming scheme used to generate names for mock objects that have not been explicitly named in the test.
      States states​(java.lang.String name)
      Returns a new state machine that is used to constrain the order in which expectations can occur.
      • Methods inherited from class junit.framework.TestCase

        assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, tearDown, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • context

        private final Mockery context
    • Constructor Detail

      • MockObjectTestCase

        public MockObjectTestCase()
      • MockObjectTestCase

        public MockObjectTestCase​(java.lang.String name)
    • Method Detail

      • initialise

        private void initialise()
      • context

        public Mockery context()
      • setDefaultResultForType

        public void setDefaultResultForType​(java.lang.Class<?> type,
                                            java.lang.Object result)
        Sets the result returned for the given type when no return value has been explicitly specified in the expectation.
        Parameters:
        type - The type for which to return result.
        result - The value to return when a method of return type type is invoked for which an explicit return value has has not been specified.
      • setImposteriser

        public void setImposteriser​(Imposteriser imposteriser)
        Changes the imposteriser used to adapt mock objects to the mocked type. The default imposteriser allows a test to mock interfaces but not classes, so you'll have to plug a different imposteriser into the Mockery if you want to mock classes.
      • setNamingScheme

        public void setNamingScheme​(MockObjectNamingScheme namingScheme)
        Changes the naming scheme used to generate names for mock objects that have not been explicitly named in the test. The default naming scheme names mock objects by lower-casing the first letter of the class name, so a mock object of type BananaSplit will be called "bananaSplit" if it is not explicitly named in the test.
      • checking

        public void checking​(ExpectationBuilder expectations)
        Specify expectations upon the mock objects in the test.
      • mock

        public <T> T mock​(java.lang.Class<T> typeToMock,
                          java.lang.String name)
        Create a mock object of type T with an explicit name.
        Parameters:
        typeToMock - The type to be mocked
        name - The name of the new mock object that is used to identify the mock object in error messages
        Returns:
        A new mock object of type
      • mock

        public <T> T mock​(java.lang.Class<T> typeToMock)
        Create a mock object of type T with a name derived from its type.
        Parameters:
        typeToMock - The type to be mocked
        Returns:
        A new mock object of type
      • sequence

        public Sequence sequence​(java.lang.String name)
        Returns a new sequence that is used to constrain the order in which expectations can occur.
        Parameters:
        name - The name of the sequence.
        Returns:
        A new sequence with the given name.
      • states

        public States states​(java.lang.String name)
        Returns a new state machine that is used to constrain the order in which expectations can occur.
        Parameters:
        name - The name of the state machine.
        Returns:
        A new state machine with the given name.