📄 listenertest.java
字号:
package org.junit.tests;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); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -