/*
 * Copyright 2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.opentestalliance;

import org.junit.Assert;
import org.junit.Test;

public class MultipleFailuresExceptionTest {

	@Test
	public void exceptionWithNoFailures() {
		MultipleFailuresException exception = new MultipleFailuresException("a name");
		Assert.assertTrue(exception.getFailures().isEmpty());
		Assert.assertFalse(exception.hasFailures());
		Assert.assertEquals("a name", exception.getMessage());
	}

	@Test
	public void exceptionWithFailures() {
		MultipleFailuresException exception = new MultipleFailuresException("a name");
		exception.addFailure(new AssertionError("failure 1"));
		exception.addFailure(new AssertionError("failure 2"));
		Assert.assertEquals(2, exception.getFailures().size());
		Assert.assertTrue(exception.hasFailures());
		Assert.assertEquals(String.format("%s%n\t%s%n\t%s", "a name", "failure 1", "failure 2"),
			exception.getMessage());
	}
}

/*
 * Copyright 2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.opentestalliance;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class MultipleFailuresExceptionTest {

	@Test
	public void exceptionWithNoFailures() {
		MultipleFailuresException exception = new MultipleFailuresException("a name");

		assertTrue(exception.getFailures().isEmpty());
		assertFalse(exception.hasFailures());
		assertEquals("a name", exception.getMessage());
	}

	@Test
	public void exceptionWithFailures() {
		MultipleFailuresException exception = new MultipleFailuresException("a name");
		exception.addFailure(new AssertionError("failure 1"));
		exception.addFailure(new AssertionError("failure 2"));

		assertEquals(2, exception.getFailures().size());
		assertTrue(exception.hasFailures());
		assertEquals(String.format("%s%n\t%s%n\t%s", "a name", "failure 1", "failure 2"), exception.getMessage());
	}
}

Use static imports for assertions