Conversation
|
Draft since I'd like to discuss first |
|
Looks good. Is more typical like that. Does not change the exercise at all. |
|
@codecop what's the best option to spread this change over all branches? Shall I open a PR for each affected branch or can you cherry-pick the commit on them? |
Changed instance variables to final for immutability.
|
Just saw that the fields have |
|
There are many branches here that I do not know. main and with_tests are usually the current and important ones. Maybe you know more about them. Let's please start with these two |
|
Added two commits: |
On main there are no member variables (this is the todo in the kata). The public modifiers on main have already been removed with 8bc02ac 20 months ago. |
|
Sometimes I compare both branches in a tool that shows me all diffs. |
There is no need to create the instances inside the
setUpmethod.In our coaching sessions, we often observe that it is not widely known that JUnit creates member variables anew for each test. As a result, there are often
@BeforeEach-annotated methods that are not necessary. This is another argument for the refactoring, as initialization can be done directly at the declaration.Another minor change (second commit cb06ed6) is the remove of
pulblicmodifiers which are not necessary with JUnit5 or newer.On a related note, I personally prefer leaving field members without access modifiers in JUnit 5 tests (i.e., no
private). However, this is just my personal style, and I understand that some IDEs or tools might flag this and suggest making the membersprivate. For this reason, I decided not to propose this change.What do you think about this change(s)? I wanted to discuss it first because I would have to make an additional PR for each further branch. Alternatively, a maintainer could do cherry-picking to avoid those PRs.