Package org.junit.tests.listening

Source Code of org.junit.tests.listening.ListenerTest$OneTest

package org.junit.tests.listening;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.notification.RunListener;

public class ListenerTest {
    static private String log;

    public static class OneTest {
        @Test
        public void nothing() {
        }
    }

    @Test
    public void notifyListenersInTheOrderInWhichTheyAreAdded() {
        JUnitCore core = new JUnitCore();
        log = "";
        core.addListener(new RunListener() {
            @Override
            public void testRunStarted(Description description) throws Exception {
                log += "first ";
            }
        });
        core.addListener(new RunListener() {
            @Override
            public void testRunStarted(Description description) throws Exception {
                log += "second ";
            }
        });
        core.run(OneTest.class);
        assertEquals("first second ", log);
    }
}
TOP

Related Classes of org.junit.tests.listening.ListenerTest$OneTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.