📄 junit4classrunnertest.java
字号:
package org.junit.tests.deprecated;import static org.hamcrest.CoreMatchers.is;import static org.junit.Assert.assertThat;import static org.junit.Assert.fail;import org.junit.Test;import org.junit.internal.runners.JUnit4ClassRunner;import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.RunWith;/* * @deprecated This is a simple smoke test to make sure the old JUnit4ClassRunner basically works. * Delete this test when JUnit4ClassRunner goes to the Great Heap In The Sky. */@Deprecatedpublic class JUnit4ClassRunnerTest { @SuppressWarnings("deprecation") @RunWith(JUnit4ClassRunner.class) public static class Example { @Test public void success() {} @Test public void failure() { fail(); } } @Test public void runWithOldJUnit4ClassRunner() { Result result= JUnitCore.runClasses(Example.class); assertThat(result.getRunCount(), is(2)); assertThat(result.getFailureCount(), is(1)); } @SuppressWarnings("deprecation") @RunWith(JUnit4ClassRunner.class) public static class UnconstructableExample { public UnconstructableExample() { throw new UnsupportedOperationException(); } @Test public void success() {} @Test public void failure() { fail(); } } @Test public void runWithOldJUnit4ClassRunnerAndBadConstructor() { Result result= JUnitCore.runClasses(UnconstructableExample.class); assertThat(result.getRunCount(), is(2)); assertThat(result.getFailureCount(), is(2)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -