📄 junitcorereturnscorrectexitcodetest.java
字号:
package org.junit.tests.running.core;import static org.junit.Assert.assertEquals;import static org.junit.Assert.fail;import org.junit.Test;import org.junit.runner.JUnitCore;import org.junit.tests.TestSystem;public class JUnitCoreReturnsCorrectExitCodeTest { static public class Fail { @Test public void kaboom() { fail(); } } @Test public void failureCausesExitCodeOf1() throws Exception { runClass(getClass().getName() + "$Fail", 1); } @Test public void missingClassCausesExitCodeOf1() throws Exception { runClass("Foo", 1); } static public class Succeed { @Test public void peacefulSilence() { } } @Test public void successCausesExitCodeOf0() throws Exception { runClass(getClass().getName() + "$Succeed", 0); } private void runClass(String className, int returnCode) { TestSystem system= new TestSystem(); JUnitCore.runMainAndExit(system, className); assertEquals(returnCode, system.fCode); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -