summaryrefslogtreecommitdiffstats
path: root/junit4/src/test/java/org/junit/tests/validation/FailedConstructionTest.java
blob: 7d2ab1e9105b21e09aa161e4e7646ecea17d279d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.junit.tests.validation;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class FailedConstructionTest {
	public static class CantConstruct {
		public CantConstruct() {
			throw new RuntimeException();
		}

		@Test
		public void foo() {
		}
	}

	@Test
	public void failedConstructionIsTestFailure() {
		Result result= JUnitCore.runClasses(CantConstruct.class);
		Failure failure= result.getFailures().get(0);
		Description expected= Description.createTestDescription(CantConstruct.class, "foo");
		Assert.assertEquals(expected, failure.getDescription());
	}
}