Search in sources :

Example 1 with PreconditionViolationException

use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.

the class CsvFileArgumentsProviderTests method throwsExceptionForMissingClasspathResource.

@Test
void throwsExceptionForMissingClasspathResource() {
    CsvFileSource annotation = annotation("UTF-8", "\n", ',', "does-not-exist.csv");
    PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> provide(new CsvFileArgumentsProvider(), annotation).toArray());
    assertThat(exception).hasMessageContaining("Classpath resource does not exist: does-not-exist.csv");
}
Also used : PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Test(org.junit.jupiter.api.Test)

Example 2 with PreconditionViolationException

use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.

the class MethodArgumentsProviderTests method throwsExceptionWhenNoTestClassIsAvailable.

@Test
void throwsExceptionWhenNoTestClassIsAvailable() {
    PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> provideArguments((Class<?>) null, null, false, "someMethod"));
    assertThat(exception).hasMessageContaining("required test class is not present");
}
Also used : PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Test(org.junit.jupiter.api.Test)

Example 3 with PreconditionViolationException

use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.

the class MethodArgumentsProviderTests method throwsExceptionForIllegalReturnType.

@Test
void throwsExceptionForIllegalReturnType() {
    PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> provideArguments("providerWithIllegalReturnType").toArray());
    assertThat(exception).hasMessageContaining("Cannot convert instance of java.lang.Integer into a Stream");
}
Also used : PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Test(org.junit.jupiter.api.Test)

Example 4 with PreconditionViolationException

use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.

the class ValueArgumentsProviderTests method onlyEmptyInputsAreNotAllowed.

@Test
void onlyEmptyInputsAreNotAllowed() {
    PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> provideArguments(new short[0], new byte[0], new int[0], new long[0], new float[0], new double[0], new char[0], new String[0], new Class<?>[0]));
    assertThat(exception).hasMessageContaining("Exactly one type of input must be provided in the @ValueSource annotation, but there were 0");
}
Also used : PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Test(org.junit.jupiter.api.Test)

Example 5 with PreconditionViolationException

use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.

the class TagFilterTests method assertSyntaxViolationForIncludes.

private void assertSyntaxViolationForIncludes(String tag) {
    PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> includeTags(tag));
    assertThat(exception).hasMessageStartingWith("Unable to parse tag expression");
}
Also used : PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException)

Aggregations

PreconditionViolationException (org.junit.platform.commons.util.PreconditionViolationException)18 Test (org.junit.jupiter.api.Test)12 DemoHierarchicalTestEngine (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine)3 IOException (java.io.IOException)2 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)2 TemporaryFolder (org.junit.rules.TemporaryFolder)1 Verifier (org.junit.rules.Verifier)1