test: improve SourceRoot coverage and apply spotless formatting #4795#4881
test: improve SourceRoot coverage and apply spotless formatting #4795#4881jlerbsc merged 5 commits intojavaparser:masterfrom
Conversation
|
Hi! |
|
|
||
| @Test | ||
| void saveAllPreservesAbsolutePaths() throws Exception { | ||
| Path tmp = Files.createTempDirectory("jp-core-"); |
There was a problem hiding this comment.
It is not advisable to create temporary directories if they are not deleted after the test.
| Files.createDirectories(oldRoot); | ||
|
|
||
| SourceRoot sr = new SourceRoot(oldRoot); | ||
| CompilationUnit cuRel = new CompilationUnit(); |
There was a problem hiding this comment.
It would be clearer to parse a string to create your class.
|
Thanks a lot for your suggestion! I’ve updated the test to parse a string when creating the class. Really appreciate your careful review. |
| Path oldRoot = tmp.resolve("old"); | ||
| Path newRoot = tmp.resolve("new"); | ||
|
|
||
| Files.createDirectories(oldRoot); |
There was a problem hiding this comment.
There is also a directory created here that is not deleted.
|
Thanks a lot for your suggestion! I’ve fixed the issue and updated the test accordingly. Really appreciate your careful review. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4881 +/- ##
===============================================
+ Coverage 58.333% 58.401% +0.067%
Complexity 2535 2535
===============================================
Files 677 677
Lines 39041 39047 +6
Branches 7089 7089
===============================================
+ Hits 22774 22804 +30
+ Misses 13368 13343 -25
- Partials 2899 2900 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
Hi, I noticed that the Spotless check still failed in CI. ./mvnw spotless:apply Both commands completed successfully on my side, and no formatting differences were shown afterwards. Thanks a lot for your time and help! |
|
Thanks a lot for pointing that out! |
|
Thank you for this contribution. |

Summary
Improves test coverage for SourceRoot by adding more unit tests covering path resolution and saveAll behavior.
These additions help ensure correct handling of both relative and absolute paths during file saving and normalization.
Details
Added new test cases in SourceRootTest.java to increase branch and path coverage
Verified that saveAll() preserves absolute paths correctly
Applied ./mvnw spotless:apply for consistent formatting
Related issue
#4795