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
[junit] Use junit-platform-testkit for testing extensions #116
Comments
And I forgot point 3, which was the one that actually prompted me to raise this issue: when low-level unit testing, you often end up testing behaviour that doesn't need to be tested. Not only is this a waste of time, it also means that when you refactor that code you break a bunch of all the lower-level tests even though the higher-level tests continue to pass, and you spend additional time fixing the broken test code. My specific example: in |
I personally never really got into mock testing. Seems like too much voodoo magic to me :-) So I would be fine with this approach. |
I've found that mocks are good for simple tests (eg, for supplying a callback listener interface). But as the tests get more complicated, it's simpler to write concrete mock classes (where the API permits) than to build them up in code using the mocking library. But even this is inferior (IMO) to testing against real code for anything but the simpler cases. I know that some testing enthusiasts are obsessed with the speed of their tests and want to mock everything that might be slow - but IMO, there's no point rapidly being able to test your code if the tests are not accurate. |
I have learned in the last couple of years that mocking as a testing technique is fraught, especially as your level of functionality increases:
For this reason, I think it is almost always better to test against real code (where practical) rather than mocks.
Having wrestled briefly with #113 and #114, I think we have reached that point now where our mock-based tests are getting difficult to maintain and error-prone. Though it will involve a bit of work, I think we would be well served for the long time by putting in that effort now to port them to use
junit-platform-testkit
. I think that AssertJ's tests forSoftAssertionsExtension
are a good model to follow (they were written by one of the core Jupiter developers): https://github.com/joel-costigliola/assertj-core/tree/master/src/test/java/org/assertj/core/api/junit/jupiterThe text was updated successfully, but these errors were encountered: