⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parameterizedassertionerrortest.java

📁 junit
💻 JAVA
字号:
package org.junit.tests.experimental.theories;import static org.hamcrest.CoreMatchers.is;import static org.hamcrest.CoreMatchers.not;import static org.junit.Assert.assertThat;import static org.junit.Assume.assumeThat;import static org.junit.internal.matchers.StringContains.containsString;import org.junit.Test;import org.junit.experimental.theories.Theories;import org.junit.experimental.theories.Theory;import org.junit.experimental.theories.internal.ParameterizedAssertionError;import org.junit.runner.RunWith;@RunWith(Theories.class)public class ParameterizedAssertionErrorTest {	public static final String METHOD_NAME= "methodName";	public static final NullPointerException NULL_POINTER_EXCEPTION= new NullPointerException();	public static Object[] NO_OBJECTS= new Object[0];	public static ParameterizedAssertionError A= new ParameterizedAssertionError(			NULL_POINTER_EXCEPTION, METHOD_NAME);	public static ParameterizedAssertionError B= new ParameterizedAssertionError(			NULL_POINTER_EXCEPTION, METHOD_NAME);	public static ParameterizedAssertionError B2= new ParameterizedAssertionError(			NULL_POINTER_EXCEPTION, "methodName2");	@Theory	public void equalParameterizedAssertionErrorsHaveSameToString(			ParameterizedAssertionError a, ParameterizedAssertionError b) {		assumeThat(a, is(b));		assertThat(a.toString(), is(b.toString()));	}	@Theory	public void differentParameterizedAssertionErrorsHaveDifferentToStrings(			ParameterizedAssertionError a, ParameterizedAssertionError b) {		assumeThat(a, not(b));		assertThat(a.toString(), not(b.toString()));	}	@Theory	public void equalsReturnsTrue(Throwable targetException, String methodName,			Object[] params) {		assertThat(new ParameterizedAssertionError(targetException, methodName,				params), is(new ParameterizedAssertionError(targetException,				methodName, params)));	}	@Theory(nullsAccepted= false)	public void buildParameterizedAssertionError(String methodName, String param) {		assertThat(new ParameterizedAssertionError(new RuntimeException(),				methodName, param).toString(), containsString(methodName));	}	@Test	public void canJoinWhenToStringFails() {		assertThat(ParameterizedAssertionError.join(" ", new Object() {			@Override			public String toString() {				throw new UnsupportedOperationException();			}		}), is("[toString failed]"));	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -