blob: b3003394797baf34a5d67e8fcabe7573d03d28a7 [file] [log] [blame]
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 {
private static 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);
}
}