Work on junit tests#12
Open
sknull wants to merge 4 commits into
Open
Conversation
sknull
commented
Dec 4, 2025
| } | ||
| } | ||
|
|
||
| private static boolean append(File fromFile1, File fromFile2, File toFile) { |
Author
There was a problem hiding this comment.
most stuff here is moved into the AbstractBaseTestCase
sknull
commented
Dec 4, 2025
| @@ -0,0 +1,197 @@ | |||
| package org.jaudiotagger; | |||
Author
There was a problem hiding this comment.
Most stuff here moved from AbstractTestCase and deals with resources needed in the tests.
sknull
commented
Dec 4, 2025
| import org.jaudiotagger.tag.TagOptionSingleton; | ||
|
|
||
| public class FilePermissionsTest { | ||
| public class FilePermissionsTest extends AbstractBaseTestCase { |
|
|
||
| final String parent = sourceFile.getParent(); | ||
| File destinationNoExtension = new File(parent, DESTINATION_FILE_NAME); | ||
| File destinationNoExtension = tempFileResource(DESTINATION_FILE_NAME); |
Author
There was a problem hiding this comment.
this is now using a centralized method in the base class
| public class Issue290Test extends AbstractTestCase { | ||
|
|
||
| @Test | ||
| @EnabledIf("executeAlsoWithMissingResources") // to be configured in AbsractBaseTestCase |
Author
There was a problem hiding this comment.
This is using the method in the base named as the argument of the annotation which returns a boolean value (now set to false).
If you want to execute these tests you may do so by changing the return value in that method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Howdy,
to make things easier I decided to toss all changes in the main code (those have been made in context of converting to kotlin) and only include changes in the JUnit test code.
Reasons for changing was that a lot of tests are not working really due to missing test files (maybe those are only present on the original authors machine). In modern JUnit wee can enable/disable conditionally (here I used a flagMethod in the base test class).
Additionally I discoverd a basic misunderstanding of JUnit tests where some error counter was set to zero, the tests executed within a try catch block, counting the error counter on catch and afterwards asserting a 0 error count. This is supercomplicated and not needed as the basic concept is that wehen an exception is thrown, the test fails (this is implicitly the same the original code wanted to achieve). Also I changed the resource loading with the use of the class loader.