Open aidenywl opened 5 years ago
While IntelliJ does provide a runtime environment, the code coverage analysis is static in nature (code is analysed without executing the instructions). You can check more about this here: IntelliJ Static Code Analysis.
I believe some code analysis can be done in a static manner, but I believe test coverage is only done dynamically? (after running the code) ?
if I not wrong, code coverage should be dynamically, only after running the code then it know how much path, branch etc covered.
[Running with Coverage IntelliJ IDEA provides a dedicated action that allows you to perform run with code coverage measurement]
from https://www.jetbrains.com/help/idea/running-test-with-coverage.html
Coverage analysis normally requires the tests to be run first, which means it is not static but dynamic analysis. Last time I checked, Intellij requires running of tests prior to generating coverage stats too. But intellij can provide a whole lot of other information based on static analysis e.g., dead code, unused variables, redundant parentheses, etc.
Would it be right to say that static analysis encompasses all forms of code analysis in a non-runtime environment, while dynamic analysis requires a run-time environment?
In the scenario of Code Coverage, these would be static analysis (please correct me if i am wrong):
While these would be considered Dynamic Analysis:
Furthermore, looking at question A.41 of the mock paper, for Intellij, I'm uncertain whether dynamic or static analysis is used. The video here https://www.youtube.com/watch?v=yNYzZvyA2ik was not clear. It seems that if only statement coverage is reported, Intellij's code coverage would be an example of a static analysis?