Overview | Package | Class | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package org.jmock.integration.junit4

Integrates jMock with JUnit 4.

See:
Description

Class Summary
JMock | A test `Runner` that asserts that all expectations have been met after the test has finished and before the fixture is torn down.
JUnit4Mockery | A `Mockery` that reports expectation errors as JUnit 4 test failures.

## Package org.jmock.integration.junit4 Description

Integrates jMock with JUnit 4.

To write a mock object test in JUnit 4, declare a field of type Mockery that holds a JUnit4Mockery and annotate your test class with `@RunWith(JMock.class)`, as shown below. The Mockery will be verified after the test has run and before the fixture is torn down.

    import org.jmock.Expectations;
    import org.jmock.Mockery;
    import org.jmock.integration.junit4.JMock;
    import org.jmock.integration.junit4.JUnit4Mockery;
    import org.junit.Test;
    import org.junit.runner.RunWith;

    ...

    @RunWith(JMock.class)
    public class ExampleJUnit4MockObjectTest {
            Mockery context = new JUnit4Mockery();

            ...

            @Test public void
            dispatchesEventToSessionsOtherThanThenSender() {
                    ...

                    context.checking(new Expectations() {{
                            ...
                    }});

                    ...
            }
    }

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES