Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JUnit Jupiter best practices#299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
slachiewicz wants to merge1 commit intocodehaus-plexus:master
base:master
Choose a base branch
Loading
fromslachiewicz:feature/j-unit-jupiter-best-practices
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ void setUp() {
* @throws java.net.URISyntaxException if any.
*/
@Test
void crossPlatformIncludesString() throwsIOException, URISyntaxException {
void crossPlatformIncludesString() throwsException {
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(new File(getTestResourcesDir() + File.separator + "directory-scanner").getCanonicalFile());

Expand All@@ -93,7 +93,7 @@ void crossPlatformIncludesString() throws IOException, URISyntaxException {
* @throws java.net.URISyntaxException if any.
*/
@Test
void crossPlatformExcludesString() throwsIOException, URISyntaxException {
void crossPlatformExcludesString() throwsException {
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(new File(getTestResourcesDir() + File.separator + "directory-scanner").getCanonicalFile());
ds.setIncludes(new String[] {"**"});
Expand DownExpand Up@@ -173,7 +173,7 @@ private boolean checkTestFilesSymlinks() {
* @throws java.io.IOException if any.
*/
@Test
void general() throwsIOException {
void general() throwsException {
this.createTestFiles();

String includes = "scanner1.dat,scanner2.dat,scanner3.dat,scanner4.dat,scanner5.dat";
Expand All@@ -193,7 +193,7 @@ void general() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void includesExcludesWithWhiteSpaces() throwsIOException {
void includesExcludesWithWhiteSpaces() throwsException {
this.createTestFiles();

String includes = "scanner1.dat,\n \n,scanner2.dat \n\r, scanner3.dat\n, \tscanner4.dat,scanner5.dat\n,";
Expand DownExpand Up@@ -294,7 +294,7 @@ private void createTestDirectories() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void directoriesWithHyphens() throwsIOException {
void directoriesWithHyphens() throwsException {
this.createTestDirectories();

DirectoryScanner ds = new DirectoryScanner();
Expand All@@ -316,7 +316,7 @@ void directoriesWithHyphens() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void antExcludesOverrideIncludes() throwsIOException {
void antExcludesOverrideIncludes() throwsException {
printTestHeader();

File dir = new File(testDir, "regex-dir");
Expand DownExpand Up@@ -354,7 +354,7 @@ void antExcludesOverrideIncludes() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void antExcludesOverrideIncludesWithExplicitAntPrefix() throwsIOException {
void antExcludesOverrideIncludesWithExplicitAntPrefix() throwsException {
printTestHeader();

File dir = new File(testDir, "regex-dir");
Expand DownExpand Up@@ -393,7 +393,7 @@ void antExcludesOverrideIncludesWithExplicitAntPrefix() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void regexIncludeWithExcludedPrefixDirs() throwsIOException {
void regexIncludeWithExcludedPrefixDirs() throwsException {
printTestHeader();

File dir = new File(testDir, "regex-dir");
Expand DownExpand Up@@ -427,7 +427,7 @@ void regexIncludeWithExcludedPrefixDirs() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void regexExcludeWithNegativeLookahead() throwsIOException {
void regexExcludeWithNegativeLookahead() throwsException {
printTestHeader();

File dir = new File(testDir, "regex-dir");
Expand DownExpand Up@@ -466,7 +466,7 @@ void regexExcludeWithNegativeLookahead() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void regexWithSlashInsideCharacterClass() throwsIOException {
void regexWithSlashInsideCharacterClass() throwsException {
printTestHeader();

File dir = new File(testDir, "regex-dir");
Expand DownExpand Up@@ -507,7 +507,7 @@ void regexWithSlashInsideCharacterClass() throws IOException {
* @throws java.io.IOException if occurs an I/O error.
*/
@Test
void doNotScanUnnecesaryDirectories() throwsIOException {
void doNotScanUnnecesaryDirectories() throwsException {
createTestDirectories();

// create additional directories 'anotherDir1', 'anotherDir2' and 'anotherDir3' with a 'file1.dat' file
Expand DownExpand Up@@ -576,7 +576,7 @@ protected void scandir(File dir, String vpath, boolean fast) {
* @throws java.io.IOException if any.
*/
@Test
void isSymbolicLink() throwsIOException {
void isSymbolicLink() throwsException {
assumeTrue(checkTestFilesSymlinks());

final File directory = new File("src/test/resources/symlinks/src");
Expand All@@ -593,7 +593,7 @@ void isSymbolicLink() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void isParentSymbolicLink() throwsIOException {
void isParentSymbolicLink() throwsException {
assumeTrue(checkTestFilesSymlinks());

final File directory = new File("src/test/resources/symlinks/src");
Expand Down
16 changes: 7 additions & 9 deletionssrc/test/java/org/codehaus/plexus/util/FileUtilsTest.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -220,7 +220,6 @@ void mkdir() {
FileUtils.mkdir(winFile.getAbsolutePath());
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
}
}
}
Expand DownExpand Up@@ -358,7 +357,6 @@ void forceMkdir() throws Exception {
FileUtils.forceMkdir(winFile);
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
}
}
}
Expand DownExpand Up@@ -1243,7 +1241,7 @@ void filteredWithoutFilterAndOlderFileAndOverwrite() throws Exception {
* @throws java.io.IOException if any.
*/
@Test
void fileRead() throwsIOException {
void fileRead() throwsException {
File testFile = new File(getTestDirectory(), "testFileRead.txt");
String testFileName = testFile.getAbsolutePath();
/*
Expand DownExpand Up@@ -1272,7 +1270,7 @@ void fileRead() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void fileReadWithEncoding() throwsIOException {
void fileReadWithEncoding() throwsException {
String encoding = "UTF-8";
File testFile = new File(getTestDirectory(), "testFileRead.txt");
String testFileName = testFile.getAbsolutePath();
Expand All@@ -1297,7 +1295,7 @@ void fileReadWithEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void fileAppend() throwsIOException {
void fileAppend() throwsException {
String baseString = "abc";
File testFile = new File(getTestDirectory(), "testFileAppend.txt");
String testFileName = testFile.getAbsolutePath();
Expand All@@ -1322,7 +1320,7 @@ void fileAppend() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void fileAppendWithEncoding() throwsIOException {
void fileAppendWithEncoding() throwsException {
String baseString = "abc";
String encoding = "UTF-8";
File testFile = new File(getTestDirectory(), "testFileAppend.txt");
Expand All@@ -1348,7 +1346,7 @@ void fileAppendWithEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void fileWrite() throwsIOException {
void fileWrite() throwsException {
File testFile = new File(getTestDirectory(), "testFileWrite.txt");
String testFileName = testFile.getAbsolutePath();
// unicode escaped Japanese hiragana, "aiueo" + Umlaut a
Expand All@@ -1364,7 +1362,7 @@ void fileWrite() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
void fileWriteWithEncoding() throwsIOException {
void fileWriteWithEncoding() throwsException {
String encoding = "UTF-8";
File testFile = new File(getTestDirectory(), "testFileWrite.txt");
String testFileName = testFile.getAbsolutePath();
Expand DownExpand Up@@ -1422,7 +1420,7 @@ void deleteLongPathOnWindows() throws Exception {
* @throws java.io.IOException if any.
*/
@Test
void copyFileOnSameFile() throwsIOException {
void copyFileOnSameFile() throwsException {
String content = "ggrgreeeeeeeeeeeeeeeeeeeeeeeoierjgioejrgiojregioejrgufcdxivbsdibgfizgerfyaezgv!zeez";
final File theFile = File.createTempFile("test", ".txt");
theFile.deleteOnExit();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ class LineOrientedInterpolatingReaderTest {
* @throws java.io.IOException if any.
*/
@Test
void shouldInterpolateExpressionAtEndOfDataWithInvalidEndToken() throwsIOException {
void shouldInterpolateExpressionAtEndOfDataWithInvalidEndToken() throwsException {
String testStr = "This is a ${test";
LineOrientedInterpolatingReader iReader = new LineOrientedInterpolatingReader(
new StringReader(testStr), Collections.singletonMap("test", "TestValue"));
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@
* @see org.codehaus.plexus.util.ReflectionUtils
* @since 3.4.0
*/
publicfinal class ReflectionUtilsTest {
final class ReflectionUtilsTest {
private final ReflectionUtilsTestClass testClass = new ReflectionUtilsTestClass();

/**
Expand All@@ -40,7 +40,7 @@ public final class ReflectionUtilsTest {
* @throws java.lang.IllegalAccessException if any.
*/
@Test
void simpleVariableAccess() throwsIllegalAccessException {
void simpleVariableAccess() throwsException {
assertEquals("woohoo", ReflectionUtils.getValueIncludingSuperclasses("myString", testClass));
}

Expand All@@ -50,7 +50,7 @@ void simpleVariableAccess() throws IllegalAccessException {
* @throws java.lang.IllegalAccessException if any.
*/
@Test
void complexVariableAccess() throwsIllegalAccessException {
void complexVariableAccess() throwsException {
Map<String, Object> map = ReflectionUtils.getVariablesAndValuesIncludingSuperclasses(testClass);

Map myMap = (Map) map.get("myMap");
Expand All@@ -65,7 +65,7 @@ void complexVariableAccess() throws IllegalAccessException {
* @throws java.lang.IllegalAccessException if any.
*/
@Test
void superClassVariableAccess() throwsIllegalAccessException {
void superClassVariableAccess() throwsException {
assertEquals("super-duper", ReflectionUtils.getValueIncludingSuperclasses("mySuperString", testClass));
}

Expand All@@ -75,7 +75,7 @@ void superClassVariableAccess() throws IllegalAccessException {
* @throws java.lang.IllegalAccessException if any.
*/
@Test
void settingVariableValue() throwsIllegalAccessException {
void settingVariableValue() throwsException {
ReflectionUtils.setVariableValueInObject(testClass, "mySettableString", "mySetString");

assertEquals("mySetString", ReflectionUtils.getValueIncludingSuperclasses("mySettableString", testClass));
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -323,7 +323,6 @@ void unifyLineSeparators() throws Exception {
StringUtils.unifyLineSeparators(s, "abs");
fail("Exception NOT catched");
} catch (IllegalArgumentException e) {
assertTrue(true, "Exception catched");
}

assertEquals("this\nis\na\ntest", StringUtils.unifyLineSeparators(s, "\n"));
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,12 +21,9 @@
import java.util.Properties;

import org.codehaus.plexus.util.Os;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.*;

/**
* <p>CommandLineUtilsTest class.</p>
Expand All@@ -43,7 +40,7 @@ class CommandLineUtilsTest {
*/
@Test
void quoteArguments() {
Assertions.assertDoesNotThrow(() -> {
assertDoesNotThrow(() -> {
String result = CommandLineUtils.quote("Hello");
System.out.println(result);
assertEquals("Hello", result);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,14 +18,9 @@

import java.util.List;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.*;

/**
* <p>CycleDetectorTest class.</p>
Expand All@@ -45,7 +40,7 @@ void cycyleDetection() {
//
// a --> b --->c
//
Assertions.assertDoesNotThrow(
assertDoesNotThrow(
() -> {
final DAG dag1 = new DAG();

Expand DownExpand Up@@ -89,7 +84,7 @@ void cycyleDetection() {
// a --> b
// | | --> d
// --------->
Assertions.assertDoesNotThrow(
assertDoesNotThrow(
() -> {
final DAG dag3 = new DAG();

Expand Down
4 changes: 2 additions & 2 deletionssrc/test/java/org/codehaus/plexus/util/dag/DAGTest.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,7 +40,7 @@ class DAGTest {
* @throws org.codehaus.plexus.util.dag.CycleDetectedException if any.
*/
@Test
void dag() throwsCycleDetectedException {
void dag() throwsException {
final DAG dag = new DAG();

dag.addVertex("a");
Expand DownExpand Up@@ -146,7 +146,7 @@ void dag() throws CycleDetectedException {
* @throws org.codehaus.plexus.util.dag.CycleDetectedException if any.
*/
@Test
void getPredecessors() throwsCycleDetectedException {
void getPredecessors() throwsException {
final DAG dag = new DAG();

dag.addEdge("a", "b");
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ class TopologicalSorterTest {
* @throws org.codehaus.plexus.util.dag.CycleDetectedException if any.
*/
@Test
void dfs() throwsCycleDetectedException {
void dfs() throwsException {
// a --> b --->c
//
// result a,b,c
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ private void waitLastModified() throws IOException, InterruptedException {
}

@Test
void writeNoExistingFile() throwsIOException, InterruptedException {
void writeNoExistingFile() throwsException {
byte[] data = "Hello world!".getBytes(StandardCharsets.UTF_8);
Path path = tempDir.resolve("file.txt");
assertFalse(Files.exists(path));
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ private void waitLastModified() throws IOException, InterruptedException {
}

@Test
void noOverwriteWithFlush() throwsIOException, InterruptedException {
void noOverwriteWithFlush() throwsException {
String data = "Hello world!";
Path path = tempDir.resolve("file-bigger.txt");
assertFalse(Files.exists(path));
Expand All@@ -85,7 +85,7 @@ void noOverwriteWithFlush() throws IOException, InterruptedException {
}

@Test
void writeNoExistingFile() throwsIOException, InterruptedException {
void writeNoExistingFile() throwsException {
String data = "Hello world!";
Path path = tempDir.resolve("file.txt");
assertFalse(Files.exists(path));
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp