All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jmock.example.gettingstarted.GettingStartedJUnit4Mockomatic Maven / Gradle / Ivy

There is a newer version: 2.13.1
Show newest version
package org.jmock.example.gettingstarted;

import org.jmock.Expectations;
import org.jmock.auto.Mock;
import org.jmock.integration.junit4.JUnitRuleMockery;
import org.junit.Rule;
import org.junit.Test;

public class GettingStartedJUnit4Mockomatic {
    @Rule
    public JUnitRuleMockery context = new JUnitRuleMockery();

    @Mock Subscriber subscriber;
    
    @Test
    public void oneSubscriberReceivesAMessage() {
        // set up

        Publisher publisher = new Publisher();
        publisher.add(subscriber);

        final String message = "message";

        // expectations
        context.checking(new Expectations() {{
            oneOf(subscriber).receive(message);
        }});

        // execute
        publisher.publish(message);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy