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

Unit tests #58

Merged
merged 10 commits into from
Aug 6, 2019
Merged

Unit tests #58

merged 10 commits into from
Aug 6, 2019

Conversation

stopalopa
Copy link
Contributor

@stopalopa stopalopa requested a review from a team August 2, 2019 06:16
@stopalopa
Copy link
Contributor Author

stopalopa commented Aug 2, 2019

Couple of questions/issues

  1. Is there a way to add a compareTo method and pass findBugs without also overriding the equals and hashCode methods?

  2. Haven't figured out yet why the second listPlugins unit test isn't working...I think I implemented it the same way I tested getting console output for unit testing the CLI.

  3. For checking the listPlugins input, I remember \n caused some issues on Windows and I ended up trimming the ends for the previous unit tests. I'm not sure if that's going to work for this one since there's so many new lines, unless I make each new line it's own string. Should I strip out all white space or would something like converting the \n to %n be a better solution?

@timja
Copy link
Member

timja commented Aug 2, 2019

Couple of questions/issues

  1. Is there a way to add a compareTo method and pass findBugs without also overriding the equals and hashCode methods?

You should always override equals and hashCode if you're comparing objects, your IDE should be able to generate sensible ones.

@@ -154,4 +155,13 @@ public String toString() {
}
return name + " " + version + " " + url;
}

@SuppressFBWarnings("EQ_COMPARETO_USE_OBJECT_EQUALS")
Copy link
Member

Choose a reason for hiding this comment

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

please no see my comment in the main thread

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, good to know. I thought in particular generating the hashCode method was going to be really complicated, but that was fairly easy.

}
installedPluginVersions.entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.forEach(p -> System.out.println(p.getKey() + " " + p.getValue()));
Copy link
Member

Choose a reason for hiding this comment

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

you could probably extract this to a method as it's called 3 times and then use something like:

Suggested change
.forEach(p -> System.out.println(p.getKey() + " " + p.getValue()));
.forEach(this::logPlugin);

assertEquals("", expectedNoOutput.toString().trim());
}

/*
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's currently commented out because it's not working. For some reason the value returned/output to the console is empty.

@kwhetstone
Copy link

Looks like this was hit with the pom version issues. The tests are not on the CI server.

@timja
Copy link
Member

timja commented Aug 2, 2019

@kwhetstone
Copy link

Random thought: the windows failure in the test could be line endings. You might have to do more of line by line comparison to see if the output is being printed correctly,

@stopalopa
Copy link
Contributor Author

Random thought: the windows failure in the test could be line endings. You might have to do more of line by line comparison to see if the output is being printed correctly,

Yeah, I knew this was potentially going to be a problem. See my question #3. Is there an easier way for me to test without having to push a new commit each time?

@timja
Copy link
Member

timja commented Aug 4, 2019

Random thought: the windows failure in the test could be line endings. You might have to do more of line by line comparison to see if the output is being printed correctly,

Yeah, I knew this was potentially going to be a problem. See my question #3. Is there an easier way for me to test without having to push a new commit each time?

Windows VM?

@kwhetstone
Copy link

I think what you want to do is a simple string replace for the generated string like content.replaceAll("\\r\\n?", "\n") We really don't care about what the invisible characters look like, so hard replacing them shouldn't break the display testing. I can't find anything about libraries testing for this particular thing.

@stopalopa stopalopa merged commit 246854c into jenkinsci:master Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants