-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Refactoring existing unit tests #7695
Conversation
BibDatabaseDiffTest: Assertion Roulette -> provide message to pinpoint error TestVM: Assertion Roulette / Magic Numbers -> provide message to pinpoint error, give numbers meaningful names FieldFormatterCleanupTest: Assertion Roulette -> provide message to pinpoint error (x2) OOBibStyleTest: Assertion Roulette -> provide message to pinpoint error (x3) information about test smells: https://testsmells.org/pages/testsmells.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for continuing on this.
IMHO the explanations do not help. The output of JUnit is already enough.
I will close the PR.
Please focus on improving the tests by a) adding new test cases or b) converting to paramterized tests.
assertEquals(Optional.empty(), diff.getPreambleDifferences()); | ||
assertEquals(Optional.empty(), diff.getMetaDataDifferences()); | ||
assertEquals(Collections.emptyList(), diff.getBibStringDifferences()); | ||
assertEquals(Collections.emptyList(), diff.getEntryDifferences()); | ||
assertEquals(Optional.empty(), diff.getPreambleDifferences(), "Expected preamble differences to be Optional.empty()"); | ||
assertEquals(Optional.empty(), diff.getMetaDataDifferences(), "Expected metadata differences to be Optional.empty()"); | ||
assertEquals(Collections.emptyList(), diff.getBibStringDifferences(), "Expected bibstring differences to be Collections.emptyList()"); | ||
assertEquals(Collections.emptyList(), diff.getEntryDifferences(), "Expected entry differences to be Collections.emptyList()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo these changes.
Please convert to paramterized test.
final int EXPECTED_NUMBER_OF_STRINGS = 2; | ||
final int EXPECTED_NUMBER_OF_INTEGERS = 7; | ||
final int EXPECTED_NUMBER_OF_ENTRIES = 1; | ||
final int EXPECTED_NUMBER_OF_FIELDS = 5; | ||
final int EXPECTED_NUMBER_OF_FUNCTIONS = 38; | ||
|
||
assertEquals(EXPECTED_NUMBER_OF_STRINGS, vm.getStrings().size(), "Expected getStrings() to return a map of size " + EXPECTED_NUMBER_OF_STRINGS); | ||
assertEquals(EXPECTED_NUMBER_OF_INTEGERS, vm.getIntegers().size(), "Expected getIntegers() to return a map of size " + EXPECTED_NUMBER_OF_INTEGERS); | ||
assertEquals(EXPECTED_NUMBER_OF_ENTRIES, vm.getEntries().size(), "Expected getEntries() to return a list of size " + EXPECTED_NUMBER_OF_ENTRIES); | ||
assertEquals(EXPECTED_NUMBER_OF_FIELDS, vm.getEntries().get(0).fields.size(), "Expected entry to have " + EXPECTED_NUMBER_OF_FIELDS + " fields"); | ||
assertEquals(EXPECTED_NUMBER_OF_FUNCTIONS, vm.getFunctions().size(), "Expected getFunctions() to return a map of size " + EXPECTED_NUMBER_OF_FUNCTIONS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is less readable.
assertEquals(fieldMap.get(StandardField.TITLE).toUpperCase(), entry.getField(StandardField.TITLE).get()); | ||
assertEquals(fieldMap.get(StandardField.BOOKTITLE).toUpperCase(), entry.getField(StandardField.BOOKTITLE).get()); | ||
assertEquals(fieldMap.get(StandardField.YEAR).toUpperCase(), entry.getField(StandardField.YEAR).get()); | ||
assertEquals(fieldMap.get(StandardField.MONTH).toUpperCase(), entry.getField(StandardField.MONTH).get()); | ||
assertEquals(fieldMap.get(StandardField.ABSTRACT).toUpperCase(), entry.getField(StandardField.ABSTRACT).get()); | ||
assertEquals(fieldMap.get(StandardField.DOI).toUpperCase(), entry.getField(StandardField.DOI).get()); | ||
assertEquals(fieldMap.get(StandardField.ISSN).toUpperCase(), entry.getField(StandardField.ISSN).get()); | ||
assertEquals(fieldMap.get(StandardField.TITLE).toUpperCase(), entry.getField(StandardField.TITLE).get(), "Title was not cleaned up correctly. Expected: " + fieldMap.get(StandardField.TITLE).toUpperCase() + " But was: " + entry.getField(StandardField.TITLE).get()); | ||
assertEquals(fieldMap.get(StandardField.BOOKTITLE).toUpperCase(), entry.getField(StandardField.BOOKTITLE).get(), "Booktitle was not cleaned up correctly. Expected: " + fieldMap.get(StandardField.BOOKTITLE).toUpperCase() + " But was: " + entry.getField(StandardField.BOOKTITLE).get()); | ||
assertEquals(fieldMap.get(StandardField.YEAR).toUpperCase(), entry.getField(StandardField.YEAR).get(), "Year was not cleaned up correctly. Expected: " + fieldMap.get(StandardField.YEAR).toUpperCase() + " But was: " + entry.getField(StandardField.YEAR).get()); | ||
assertEquals(fieldMap.get(StandardField.MONTH).toUpperCase(), entry.getField(StandardField.MONTH).get(), "Month was not cleaned up correctly. Expected: " + fieldMap.get(StandardField.MONTH).toUpperCase() + " But was: " + entry.getField(StandardField.MONTH).get()); | ||
assertEquals(fieldMap.get(StandardField.ABSTRACT).toUpperCase(), entry.getField(StandardField.ABSTRACT).get(), "Abstract was not cleaned up correctly. Expected: " + fieldMap.get(StandardField.ABSTRACT).toUpperCase() + " But was: " + entry.getField(StandardField.ABSTRACT).get()); | ||
assertEquals(fieldMap.get(StandardField.DOI).toUpperCase(), entry.getField(StandardField.DOI).get(), "DOI was not cleaned up correctly. Expected: " + fieldMap.get(StandardField.DOI).toUpperCase() + " But was: " + entry.getField(StandardField.DOI).get()); | ||
assertEquals(fieldMap.get(StandardField.ISSN).toUpperCase(), entry.getField(StandardField.ISSN).get(), "ISSN was not cleaned up correctly. Expected: " + fieldMap.get(StandardField.ISSN).toUpperCase() + " But was: " + entry.getField(StandardField.ISSN).get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the change
This pull request contributes to issue #6207, which is to add more unit tests or improve existing ones.
Slightly refactored Tests:
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)