?? withonlytestannotations.java
字號:
package org.junit.tests.experimental.theories.runner;import static org.hamcrest.CoreMatchers.is;import static org.junit.Assert.assertThat;import static org.junit.experimental.results.PrintableResult.testResult;import static org.junit.experimental.results.ResultMatchers.failureCountIs;import static org.junit.experimental.results.ResultMatchers.isSuccessful;import org.junit.Test;import org.junit.experimental.theories.Theories;import org.junit.runner.RunWith;public class WithOnlyTestAnnotations { @RunWith(Theories.class) public static class HonorExpectedException { @Test(expected= NullPointerException.class) public void shouldThrow() { } } @Test public void honorExpected() throws Exception { assertThat(testResult(HonorExpectedException.class).getFailures() .size(), is(1)); } @RunWith(Theories.class) public static class HonorExpectedExceptionPasses { @Test(expected= NullPointerException.class) public void shouldThrow() { throw new NullPointerException(); } } @Test public void honorExpectedPassing() throws Exception { assertThat(testResult(HonorExpectedExceptionPasses.class), isSuccessful()); } @RunWith(Theories.class) public static class HonorTimeout { @Test(timeout= 5) public void shouldStop() { while (true) { try { Thread.sleep(1000); } catch (InterruptedException e) { } } } } @Test public void honorTimeout() throws Exception { assertThat(testResult(HonorTimeout.class), failureCountIs(1)); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -