kinow commented on issue #461: Lang 1491
URL: https://github.com/apache/commons-lang/pull/461#issuecomment-538685144
 
 
   > "I'm still more comfortable with JUnit 4."
   > 
   > If I were you I would not disclose that information in public. JUnit 5 was 
released more than two years ago.
   > 
   > "But from what I understood, JUnit 5 now supports multiple modifiers 
instead of requiring public."
   > 
   > No, it does not. It requires that the tests are at least package-private. 
There is no library, except some security enforcing or style check tools that 
warn or fail you if an protection of a member is looser than it is needed. 
After all, you may want to call your test methods from some code that needs it 
to be public. JUnit 5 does not require it to be public, so the test methods 
should be declared only public if there is some extra use of them other than 
the JUnit 5 framework that needs them to be public.
   > 
   > "Do you have a link to the docs about why it needs to be default now, 
instead of public?"
   > 
   > Common sense when programming in Java. Every class and member should be 
declared with the least permissive modifier. Why don't we just declare 
everything public? In the case of JUnit 5 tests that is package-private.
   > 
   > I also feel some inconsistency not liking this pull request because some 
future pull-requests may still come up using the public modifier in tests and 
the same time saying that if some other pull requests (without this one merged) 
come up without the public modifier they are ok.
   
   Thanks for your reply @verhas. Do you have a link to any JUnit 5 
documentation supporting what you just said, please?
   
   I just had a look at one example of their docs 
(https://junit.org/junit5/docs/current/user-guide/), and simplified it removing 
the `Calculator`.
   
   ```java
   import static org.junit.jupiter.api.Assertions.assertEquals;
   
   import org.junit.jupiter.api.Test;
   
   public class TestTests {
   
       @Test
       void addition() {
           assertEquals(2, 2);
       }
   }
   ```
   
   Executed with Maven and Eclipse, both worked fine.
   
   ```
   [INFO] Running br.eti.kinoshita.TestTests
   [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.06 
s - in br.eti.kinoshita.TestTests
   [INFO] 
   [INFO] Results:
   [INFO] 
   [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
   [INFO] 
   [INFO] 
------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] 
------------------------------------------------------------------------
   [INFO] Total time: 01:10 min
   [INFO] Finished at: 2019-10-06T09:15:18+13:00
   [INFO] 
------------------------------------------------------------------------
   ```
   
   Changing the modifier to `public`, I got the exact same output on both, with 
no issues/warnings, etc.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to