Add `@DisplayName` to Test Methods in Practice Exercises
📝 Issue Description
This issue aims to add @DisplayName() annotations for every test method in the test files of all practice exercises in the Java track.
🔧 What You Need to Do
-
Skip unsynced exercises:
Before starting, make sure the exercise is not listed among the ones with unsynced tests in issue #2959. -
Locate the test file:
- Go to the exercise folder inside
exercises/practice/<exercise-name>/src/test. - Open the Java test file (typically named
<ExerciseName>Test.java).
- Go to the exercise folder inside
-
Find the canonical source:
- Navigate to the problem-specifications repo.
- Open the corresponding exercise folder and locate
canonical-data.json.
-
Match and annotate tests:
- The test cases in the
.jsonfile are listed in a specific order. - Match the tests in the Java file with the ones in
canonical-data.json. - For each test, copy the
"description"and use it as a@DisplayName("")annotation above the corresponding method in the Java test file.
- The test cases in the
⚠️ Important Guidelines
-
Max 15 exercises per PR:
To avoid large PRs, limit the number of exercises being updated in each PR to a maximum of 15 exercises (less is ok too). -
Do not close this issue via PRs:
Avoid referencing this issue in your PR with terms likeFixes #XXXorResolves #XXX, since this would automatically close the issue. -
Avoid reimplemented exercises:
Make sure you are not copying descriptions from tests that have been reimplemented. -
Need help?
If you have any questions, feel free to ask in the comments!
📋 Checklist of Practice Exercises
- [x] acronym
- [x] affine-cipher
- [x] all-your-base
- [x] allergies
- [x] alphametics
- [x] anagram
- [x] armstrong-numbers
- [x] atbash-cipher
- [x] bank-account
- [x] binary-search-tree
- [x] binary-search
- [x] bob
- [x] book-store
- [x] bottle-song
- [x] bowling
- [x] change
- [x] circular-2buffer
- [x] clock
- [x] collatz-conjecture
- [x] complex-numbers
- [x] connect
- [x] crypto-square
- [x] custom-set
- [x] darts
- [x] diamond
- [x] difference-of-squares
- [x] dnd-character
- [x] dominoes
- [x] dot-dsl
- [x] eliuds-eggs
- [x] error-handling
- [x] etl
- [x] flatten-array
- [x] flower-field
- [x] food-chain
- [x] forth
- [x] game-of-life
- [x] gigasecond
- [x] go-counting
- [x] grade-school
- [x] grains
- [x] grep
- [x] hamming
- [x] hangman
- [x] hello-world
- [x] high-scores
- [x] house
- [x] isbn-verifier
- [x] isogram
- [x] killer-sudoku-helper
- [x] kindergarten-garden
- [x] knapsack
- [x] largest-series-product
- [x] leap
- [x] ledger
- [x] linked-list
- [x] list-ops
- [x] luhn
- [x] markdown
- [x] matching-brackets
- [x] matrix
- [x] mazy-mice
- [x] meetup
- [x] micro-blog
- [x] nth-prime
- [x] nucleotide-count
- [x] ocr-numbers
- [x] palindrome-products
- [x] pangram
- [x] parallel-letter-frequency
- [x] pascals-triangle
- [x] perfect-numbers
- [x] phone-number
- [x] piecing-it-together
- [x] pig-latin
- [x] poker
- [x] pov
- [x] prime-factors
- [x] protein-translation
- [x] proverb
- [x] pythagorean-triplet
- [x] queen-attack
- [x] rail-fence-cipher
- [x] raindrops
- [x] rational-numbers
- [x] react
- [x] rectangles
- [x] relative-distance
- [x] resistor-color-duo
- [x] resistor-color-trio
- [x] resistor-color
- [x] rest-api
- [x] reverse-string
- [x] rna-transcription
- [x] robot-name
- [x] robot-simulator
- [x] roman-numerals
- [x] rotational-cipher
- [x] run-length-encoding
- [x] saddle-points
- [x] satellite
- [x] say
- [x] scrabble-score
- [x] secret-handshake
- [x] series
- [x] sgf-parsing
- [x] sieve
- [x] simple-cipher
- [x] simple-linked-list
- [x] space-age
- [x] spiral-matrix
- [x] square-root
- [x] state-of-tic-tac-toe
- [x] sublist
- [x] sum-of-multiples
- [x] swift-scheduling
- [x] tournament
- [x] transpose
- [x] tree-building
- [x] triangle
- [x] twelve-days
- [x] two-bucket
- [x] two-fer
- [x] variable-length-quantity
- [x] word-count
- [x] word-search
- [x] wordy
- [x] yacht
- [x] zebra-puzzle
- [x] zipper
💡 Reference Example
To understand how to properly add @DisplayName annotations based on canonical-data.json, you can refer to the test file in the Swift Scheduling exercise.
It already includes correctly formatted @DisplayName entries matching the test case descriptions, making it a good template for how your test file should look after the changes.
Hi @kahgoh & @jagdish-15
My name is Emmanuel and I'm relatively new to open source contributions. This looks like an excellent opportunity for me to improve my Java skills while contributing to Exercism, which has been incredibly helpful in my TypeScript learning journey. I'd love to work on this issue and would appreciate being assigned to it. I understand the guidelines about:
- Limiting to max 15 exercises per PR
- Checking the unsynced exercises list in issue #2959
- Matching test descriptions from canonical-data.json
- Not closing the issue via PR references
I'm planning to start with a smaller batch (maybe 5-10 exercises) for my first PR to get comfortable with the workflow, then continue with additional PRs as needed. Could you please assign me to this issue? I'm excited to contribute and help improve the Java track's test documentation! Thanks!
Thanks for taking this on @EmmanuelBerkowicz! I have just assigned this one to you.
Hey @kahgoh , I've not used IntelliJ CheckStyle before. It looks like that is the reason my pull request is not going through (ref attached image). I've restarted my IDE with the plugin installed, and it's not showing anything different. Is there anything obvious I might have overlooked or can do to push this through?
Sorry I'm not familar with the IntelliJ plugin, but I wonder if you need to do something to run it. With Gradle, you should also be to run it with ./gradlew check.
In terms of the error in the CI, this is specific error:
Error: eckstyle] [ERROR] /home/runner/work/java/java/exercises/practice/swift-scheduling/src/test/java/SwiftSchedulingTest.java:131: Line is longer than 120 characters (found 124). [LineLength]
I've also added a few comments on the PR regarding this error!
Thanks guys! I've committed the suggested change :)
@EmmanuelBerkowicz, The PR is merged now! You can now start working on other exercises.
hey @jagdish-15 , Is this closed?
Yes @EmmanuelBerkowicz, of course!
So far, you’ve raised just one PR adding display tags to one of the exercises, but as you can see in the checklist in the issue description, there are many more still pending.
Feel free to raise PRs for any of the exercises that haven’t been ticked off yet!
Hey @jagdish-15 , Which other ones are pending?
From what I can see in the list, there was only one exercise.
I'm happy to do others! But they aren't appearing for me in this issue.
All the exercises that are still unchecked are pending, which means everything except swift-scheduling.
Ahhhhhhhh... I miss interpreted this then, I thought it meant only the swift-scheduling, which is why that was the one I did in the original PR.
I'll make a dent at this then!
I'd like to help with this one
HI guys ! I am also trying to contribute into open source projects and this feels like a good opportunity . Is it okay if I contribute in it ??
Hey @jagdish-15 ,
Something has come up irl, I'm ok for this to bump onto someone else.
It doesn't look like I'll be able to give it much attention for a while :/
No problem, @EmmanuelBerkowicz, I'll go ahead and unassign you from this issue.
@Arsh0388, you can start from the bottom of the list, since @AtharvOps is beginning from the top, so that we can avoid any overlaps.
ok. Sounds good. I will start from the bottom and fix it.
Hi @kahgoh ! I have created a pr where I fixed the last 3 files. All the checks have been passed. Just waiting for someone's review and approval.
Hi! I'm new to contributions and currently learning. I would like to have this opportunity to contribute to this issue.
Please assign me to this issue. I will start from rectangles to reverse-string or as your recomendation.
I'll work on adding @DisplayName annotations to these test files following the guidelines provided.
Hi @jagdish-15, I would love to take this oppurtunity and contribute to this issue. Could you assign me so I can pick up some of the unchecked practice exercises? Thank you.