Skip to content
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

A little enhancement of report #1303

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

the-end-sea-of-the-world

Deal with issue #1100. Check the parent file of csv and xml, create if it does not exist.

@marchof
Copy link
Member

marchof commented Apr 24, 2022

Hi @the-end-sea-of-the-world, welcome to the JaCoCo project and thanks for your contribution!

We try to provide a regression test for every feature. What about adding (or extending) the existing tests to validate your code?

Also your implementation will not work on Unix/Linux system where the path separator is a forward slash /.

Instead of parsing Strings the java.io.File API allows to determine the parent folder. We already use this in our code base, for example here.

Copy link
Member

@marchof marchof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Add unit test
  • Use java.io.File API to also support Unix path separators

@the-end-sea-of-the-world
Copy link
Author

Thanks for your suggestion, I will try to modify it.

@the-end-sea-of-the-world
Copy link
Author

Hello, I have changed the code to use java.io.File API and added JUnit tests and a Maven project demo used in the test to generate a report.

@marchof
Copy link
Member

marchof commented Apr 26, 2022

@the-end-sea-of-the-world thanks for the update!

To be honest I don't think we will maintain the demo code in the JaCoCo project. May I ask you to remove it?

@@ -78,4 +78,88 @@ public void should_not_print_any_output_when_quiet_option_is_given()
assertNoOutput(err);
}

@Test
public void should_not_print_error_message_when_parent_file_of_xml_does_not_exist() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exitsting ReportTest is the better place to test the Report class.

private IReportVisitor createReportVisitor() throws IOException {
final List<IReportVisitor> visitors = new ArrayList<IReportVisitor>();

if (xml != null) {
final File folder = xml.getParentFile();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract a private method createParent() to avoid code duplication.

@marchof
Copy link
Member

marchof commented Apr 26, 2022

Also as you can see here the build fails as the source code has some formatting issues. Our development setup with Eclipse auto-formatting is described here.

@the-end-sea-of-the-world
Copy link
Author

Thanks for your advice. There are a lot of things in school these days. I will modify the code on the weekend.

@the-end-sea-of-the-world
Copy link
Author

@marchof all the problems have been solved. Is there any other one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants