use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.
the class TagFilterTests method assertSyntaxViolationForExcludes.
private void assertSyntaxViolationForExcludes(String tag) {
PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> excludeTags(tag));
assertThat(exception).hasMessageStartingWith("Unable to parse tag expression");
}
use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.
the class DefaultLauncherTests method registerTestExecutionListenersWithEmptyArray.
@Test
void registerTestExecutionListenersWithEmptyArray() {
DefaultLauncher launcher = createLauncher(new DemoHierarchicalTestEngine("dummy id"));
PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> launcher.registerTestExecutionListeners(new TestExecutionListener[0]));
assertThat(exception).hasMessageContaining("listeners array must not be null or empty");
}
use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.
the class DefaultLauncherTests method registerTestExecutionListenersWithNullArray.
@Test
void registerTestExecutionListenersWithNullArray() {
DefaultLauncher launcher = createLauncher(new DemoHierarchicalTestEngine("dummy id"));
PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> launcher.registerTestExecutionListeners((TestExecutionListener[]) null));
assertThat(exception).hasMessageContaining("listeners array must not be null or empty");
}
use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.
the class DefaultLauncherTests method registerTestExecutionListenersWithArrayContainingNullElements.
@Test
void registerTestExecutionListenersWithArrayContainingNullElements() {
DefaultLauncher launcher = createLauncher(new DemoHierarchicalTestEngine("dummy id"));
PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> launcher.registerTestExecutionListeners(new TestExecutionListener[] { null }));
assertThat(exception).hasMessageContaining("individual listeners must not be null");
}
use of org.junit.platform.commons.util.PreconditionViolationException in project junit5 by junit-team.
the class DiscoverySelectors method selectDirectory.
/**
* Create a {@code DirectorySelector} for the supplied {@linkplain File directory}.
*
* <p>This method selects the directory in its {@linkplain File#getCanonicalPath()
* canonical} form and throws a {@link PreconditionViolationException} if the
* directory does not exist.
*
* @param directory the directory to select; never {@code null}
* @see DirectorySelector
* @see #selectDirectory(String)
* @see #selectFile(String)
* @see #selectFile(File)
*/
public static DirectorySelector selectDirectory(File directory) {
Preconditions.notNull(directory, "Directory must not be null");
Preconditions.condition(directory.isDirectory(), () -> String.format("The supplied java.io.File [%s] must represent an existing directory", directory));
try {
return new DirectorySelector(directory.getCanonicalPath());
} catch (IOException ex) {
throw new PreconditionViolationException("Failed to retrieve canonical path for directory: " + directory, ex);
}
}
Aggregations