formatter-maven-plugin icon indicating copy to clipboard operation
formatter-maven-plugin copied to clipboard

Add tests for the formatter mojo caching of files, one failing

Open fralalonde opened this issue 5 years ago • 5 comments

Adding four unit tests for the FormatterMojo caching mechanism. One of the tests is failing, as a demonstration of #312. If preferred, I could make these new tests part of #313, which fixes the issue.

fralalonde avatar Dec 14 '19 03:12 fralalonde

Please refer to the test's names for a summary description of what they do.

I've tried to minimize impact on existing code but testing Mojos is tricky, so I've made some properties package-scope in order to inject the required state without going trough a complete Plexus/Maven initialization.

fralalonde avatar Dec 14 '19 04:12 fralalonde

I can't get any of these tests to pass. They all say File Not Found when I do a clean build.

ctubbsii avatar Jan 10 '20 23:01 ctubbsii

I've found the problem and fixed it. Each test case now gets its own source file copy. One test still fails, demonstrating the case where the cache isn't updated.

fralalonde avatar Jan 21 '20 20:01 fralalonde

We may want this test, not sure yet. Leaving this open. The overall issue though has been addressed on master.

hazendaz avatar Jun 27 '20 20:06 hazendaz

I'm going to look at this to see what value as caching has been cleaned up rather well now. This may still be beneficial to have an extra test. Will either apply or decline this later tonight.

hazendaz avatar Feb 27 '22 22:02 hazendaz

Given that caching has changed for the better since this PR was created, and there hasn't been any activity here in over a year, I'm closing this PR. If there is still a reason to apply a patch like this, please create a new PR based on the current state of the repo.

ctubbsii avatar Mar 22 '23 19:03 ctubbsii

For grins as I have coveralls running on my fork which shows 40% coverage currently, I added this, adjusted to get it working again, then ran check again on coverage. It raised it 7%, so I've applied on my fork as that is a healthy improvement. Not sure I liked that it abused encapsulation to avoid reflection to get at internals of the original class but 7% considering 40% originally is pretty big deal. And of course it simply worked now since the caching changes actually fixed the failure automatically.

hazendaz avatar Mar 24 '23 04:03 hazendaz