JMOCK TUTORIAL PDF

Later articles will focus on and go deeper into its capabilities. JMockit 2. Some of its strong points are its expressibility and its out-of-the-box ability to mock static and private methods. In order to create mocks and define their behavior, instead of calling methods from the mocking API, you just need to define them directly. Instead, you end up with a definition of how you want the mock to behave when called.

Author:Meztizragore Kilkree
Country:Trinidad & Tobago
Language:English (Spanish)
Genre:Career
Published (Last):4 November 2008
Pages:470
PDF File Size:16.12 Mb
ePub File Size:20.33 Mb
ISBN:254-3-53896-706-1
Downloads:86038
Price:Free* [*Free Regsitration Required]
Uploader:Zololmaran



A Publisher sends objects to zero or more Subscribers. We want to test the Publisher, which involves testing its interactions with its Subscribers. To test interactions between the Publisher and the Subscriber we will use a mock Subscriber object. First we must import the jMock classes, define our test fixture class and define a test case method.

We first set up the context in which our test will execute. We create a Publisher to test. We create a mock Subscriber that should receive the message. We then register the Subscriber with the Publisher. Finally we create a message object to publish. We expect the receive method to be called with a single argument, the message that will be sent.

The eq method is defined in the MockObjectTestCase class and specifies a " constraint 2" on the value of the argument passed to the subscriber: we expect the argument to be the equal to the message, but not necessarily the same object. If the expected calls were not made, the test will fail. Here is the complete test. More advanced topics are covered in other tutorials 4.

FISICA SARAEVA PDF

jMock 1: Getting Started

.

BREWSTER GHISELIN THE CREATIVE PROCESS PDF

jMock for beginners

.

Related Articles