4 ms·
JUnit and Mockito/PowerMock shouldn't have to exist, at all. The language should be feature-complete enough to provide built-in unit testing with mocking of eve
by selfhoster11 6y ago
JUnit and Mockito/PowerMock shouldn't have to exist, at all. The language should be feature-complete enough to provide built-in unit testing with mocking of everything under the sun (including static methods etc) - if you can provide APIs to operate on XML and obscure X.509 formats, you damn well can provide APIs and syntactic support to make modern unit testing possible and well-supported.
As it stands, the necessity to relax members to `public` all over the place drives a giant bulldozer through any remaining delusions that Java is a language where actual OOP can be achieved.
- Hermel 6y agoThe problem is that unit testing as it is often done tears the object oriented design apart. The right way to do unit testing is to not test the internal state of an object in the test code, but to instead test it within the tested object using assertions. That way, running the unit test implicitly verifies the internal state of the object without having to expose it.
- vbezhenar 6y agoUsually people (ab)use default visibility modifier for unit testing. It's not public, so it's not visible from other packages, but unit tests usually reside in the same package, so you have full access to it. But I agree that Java could use better unit test and mocking support.
- an_opabinia 6y agoSplit modules are horrible.