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

AssertFilter does not ignore the assert statement #1378

Open
morganga opened this issue Oct 21, 2022 · 6 comments
Open

AssertFilter does not ignore the assert statement #1378

morganga opened this issue Oct 21, 2022 · 6 comments
Labels
type: bug 🐛 Something isn't working

Comments

@morganga
Copy link

morganga commented Oct 21, 2022

Steps to reproduce

  • JaCoCo version: 0.8.8.20220405071
  • Operating system: Mac OS
  • Tool integration: Maven
  • Complete executable reproducer: https://github.com/morganga/jacoco-bug
  • Steps:
    mvn clean install
    the build fails (100% coverage is required) and
    the target/site/jacoco/net.gcvs.jacoco/App.java.html report does not indicate full coverage of the assert statements.

Expected behaviour

coverage of assert statement is considered complete, line in coverage report is green.
Code coverage should be considered complete with or without assertions enabled.

Actual behaviour

assert statement contains two branches and "1 of 2 branches missed", line in coverage report is yellow.

Currently the only way to obtain full coverage of an assert statement is by running the tests twice in the same test suite, once with assertions enabled, and again with assertions disabled, so both branches of the assert statement enabled test are visited.

#324 raised the problem of only 50% branch coverage. The AssertFilter introduced in 0.8.8 reduced the problem from a "2 of 4 branches missed" to a "1 of 2 branches missed". This wasn't exactly the intension of the #324 issue, which suggested "They should not be treated as code instructions."

(In case of exceptions provide FULL STACKTRACE)

@morganga morganga added the type: bug 🐛 Something isn't working label Oct 21, 2022
morganga added a commit to morganga/jacoco that referenced this issue Oct 21, 2022
@morganga
Copy link
Author

morganga commented Dec 3, 2022

I've implemented a solution in a pull request: #1379
Please take a look at the pull request, which contains screenshots of the implemented solution and a very similar alternative solution.

@ice1000
Copy link
Contributor

ice1000 commented Jan 19, 2023

Cool!!!!!!!!!!!!!!!!!!!!!!

@ice1000
Copy link
Contributor

ice1000 commented Mar 5, 2023

Hi, I believe that you need to write some tests :) The maintainers told me they only accept fully tested code.

@morganga
Copy link
Author

morganga commented Mar 8, 2023

I'm not sure what else they want. I've modified the existing test expectations.
In the comment of the AssertTarget.java assert line, and in the unit test AssertFilterTest.java

@oers
Copy link

oers commented Jun 12, 2023

I can confirm the same problems with 0.8.8 and a reduced code coverage.

@barakugav
Copy link

would love to see progress on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants