Skip to content

Conversation

@Zeglow
Copy link

@Zeglow Zeglow commented Oct 21, 2025

Refs JabRef#676

Refactored CitationKeyGeneratorTest to use parameterized tests with @ParameterizedTest and @MethodSource, reducing code duplication while maintaining test coverage.

Collaboration: This refactoring was completed in collaboration with my classmate @hisunll. We divided the work - she refactored the first half of the test class, and I refactored the second half.

Note: My classmates are also contributing to fixing this issue as part of our CS5010 coursework. cc @espertusnu

Steps to test

This is a test refactoring PR with no functional changes to the application.

  1. Run the test suite:
   ./gradlew test --tests CitationKeyGeneratorTest
  1. Verify all tests pass
  2. Review the refactored code to ensure:
    • All original test cases are preserved
    • Parameterized tests are properly structured
    • Method sources correctly provide test data
  3. Optionally, compare the test coverage before and after to confirm no regression

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

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

expected should be the first argument

assertEquals("", generateKey(createABibEntryAuthor(""), "[auth]"));
@ParameterizedTest
@MethodSource("firstAuthor")
void firstAuthor(BibEntry entry, String expected) {
Copy link
Member

Choose a reason for hiding this comment

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

expected should always be the first argument, otherwise it's confusing and inconsistent with other tests
So please adapt this throghout the file

@Siedlerchr Siedlerchr added status: changes-required Pull requests that are not yet complete dev: testing Related to tests labels Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev: testing Related to tests status: changes-required Pull requests that are not yet complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants