Skip to content

Work on junit tests#12

Open
sknull wants to merge 4 commits into
RouHim:mainfrom
sknull:work-on-junit-tests
Open

Work on junit tests#12
sknull wants to merge 4 commits into
RouHim:mainfrom
sknull:work-on-junit-tests

Conversation

@sknull
Copy link
Copy Markdown

@sknull sknull commented Dec 4, 2025

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.

}
}

private static boolean append(File fromFile1, File fromFile2, File toFile) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

most stuff here is moved into the AbstractBaseTestCase

@@ -0,0 +1,197 @@
package org.jaudiotagger;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Most stuff here moved from AbstractTestCase and deals with resources needed in the tests.

import org.jaudiotagger.tag.TagOptionSingleton;

public class FilePermissionsTest {
public class FilePermissionsTest extends AbstractBaseTestCase {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

make use of base methods


final String parent = sourceFile.getParent();
File destinationNoExtension = new File(parent, DESTINATION_FILE_NAME);
File destinationNoExtension = tempFileResource(DESTINATION_FILE_NAME);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this is now using a centralized method in the base class

public class Issue290Test extends AbstractTestCase {

@Test
@EnabledIf("executeAlsoWithMissingResources") // to be configured in AbsractBaseTestCase
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant