Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up assertions in CleanMojoTest #61

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
*/
@MojoTest
public class CleanMojoTest {
private static final String LOCAL_REPO = "target/local-repo/";

/**
* Tests the simple removal of directories
Expand Down Expand Up @@ -175,7 +174,7 @@ public void testCleanLockedFile(CleanMojo mojo) throws Exception {
mojo.execute();
fail("Should fail to delete a file that is locked");
} catch (MojoException expected) {
assertTrue(true);
assertNotNull(expected.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong too. The test should use assertThrows instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I'd call it wrong. It's simply an older style of testing these things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, converted to assertThrows

}
}

Expand All @@ -199,9 +198,6 @@ public void testCleanLockedFileWithNoError(CleanMojo mojo) throws Exception {
try (FileChannel channel = new RandomAccessFile(f, "rw").getChannel();
FileLock ignored = channel.lock()) {
mojo.execute();
assertTrue(true);
} catch (MojoException expected) {
fail("Should display a warning when deleting a file that is locked");
}
}

Expand Down