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

Improve Unit Test Coverage #123

Open
3 of 20 tasks
davewichers opened this issue Dec 30, 2021 · 0 comments
Open
3 of 20 tasks

Improve Unit Test Coverage #123

davewichers opened this issue Dec 30, 2021 · 0 comments
Assignees

Comments

@davewichers
Copy link
Collaborator

davewichers commented Dec 30, 2021

Because you mentioned that we didn't have unit tests for certain methods we were modifying, I thought it would be useful to generate some basic code coverage metrics for our unit tests, using JaCoCo. I just added some items to the pom that does two things:

  1. Generates JaCoCo reports when you run: mvn site - they are included in the Project Reports section.
  2. Generates warnings when there are classes with no test coverage for 1 or more methods.

The current warnings are:
[INFO] --- jacoco-maven-plugin:0.8.7:check (jacoco-check) @ antisamy ---
[INFO] Loading execution data file /Users/Dave.Wichers/git/ANTISAMY/antisamy_main/target/jacoco.exec
[INFO] Analyzed bundle 'antisamy' with 40 classes

  • [WARNING] Rule violated for class org.owasp.validator.html.scan.AntiSamySAXScanner: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.scan.AbstractAntiSamyScanner: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.scan.AntiSamyDOMScanner: methods missed count is 2, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.scan.Constants: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.CleanResults: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.Policy.SAXErrorHandler: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.Policy.1: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.Policy.3.1: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.Policy.2: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.AntiSamy: methods missed count is 4, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.Policy: methods missed count is 4, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.PolicyException: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.InternalPolicy: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.css.UnknownSelectorException: methods missed count is 2, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.css.CssHandler: methods missed count is 6, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.util.HTMLEntityEncoder: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.util.XMLUtil: methods missed count is 6, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.util.URIUtils: methods missed count is 4, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.model.Tag: methods missed count is 1, but expected maximum is 0
  • [WARNING] Rule violated for class org.owasp.validator.html.model.Property: methods missed count is 1, but expected maximum is 0
    [WARNING] Coverage checks have not been met. See log for details.

I'd like us to create unit tests for every PUBLIC method first, and then ideally all the methods eventually. Once we have this level of test coverage, we can consider adding some level of code coverage minimums, maybe for only critical/public methods.

Not urgent, just a potential improvement idea.

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

No branches or pull requests

2 participants