Add support for non-branch coverage goals in DynaMOSA#142
Add support for non-branch coverage goals in DynaMOSA#142Aditya-9215 wants to merge 12 commits intose2p:mainfrom
Conversation
LuKrO2011
left a comment
There was a problem hiding this comment.
Hi,
thank you for the pull request! Before requesting review for a non-draft PR, please make sure all CI checks pass. For running the checks locally, see CONTRIBUTING.md.
I assume you were working on #119 and this PR, once merged, closes #119.
|
Hi Lukas,
Thank you for your feedback!
I have addressed the CI issues (mypy and pre-commit), and all checks pass
locally now. The remaining workflow appears to require maintainer approval
to run.
This PR addresses issue #119 by extending DynaMOSA to support non-branch
coverage goals (e.g., line coverage), while preserving the existing
branch-based dependency handling.
Please let me know if any further changes are needed. I’d be happy to
refine the implementation.
Best regards,
Aditya
…On Mon, Mar 23, 2026 at 12:45 PM Lukas Krodinger ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Hi,
thank you for the pull request! Before requesting review for a non-draft
PR, please make sure all CI checks pass. For running the checks locally,
see CONTRIBUTING.md
<https://gitlab.infosun.fim.uni-passau.de/se2/pynguin/pynguin/-/blob/f270973c64250b52036441df063fe589167f4b24/CONTRIBUTING.md>
.
I assume you were working on #119
<#119> and this PR, once merged,
closes #119 <#119>.
—
Reply to this email directly, view it on GitHub
<#142?email_source=notifications&email_token=BON7X7CZQFJIWVLPK4YV4R34SDQADA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTGOJYHE3TMNRTGE32M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#pullrequestreview-3989766317>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BON7X7GYRZXTEOYUNLTJGPT4SDQADAVCNFSM6AAAAACW2PTVOGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTSOBZG43DMMZRG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
LuKrO2011
left a comment
There was a problem hiding this comment.
Hi,
thank you for your contribution. However, I can not accept the PR as it is, because of the following three reasons. This PR
- changes stuff unrelated to the issue
- removes active goal updating which breaks the idea of DynaMOSA
- does not convince me that the limitation mentioned in the issue is addressed (as there is no new test showing that this is fixed now)
|
Hi @LuKrO2011, Thanks for your feedback. I have addressed the issues:
Please let me know if any further changes are needed. |
LuKrO2011
left a comment
There was a problem hiding this comment.
Hi,
thank you for your updating your contribution. Unrelated changes to the issue have been removed successfully. However, there are still limitations:
- tests do not pass (again)
- does not convince me that the limitation mentioned in the issue is addressed (as there is no new test showing that this is fixed now)
Additionally, I question whether the proposed way of allowing for additional "non-branch" fitness functions is a good way to address the issue. While the original DynaMosa paper does not handle line coverage, generalizing from how the other coverage metrics (statement, branch and mutation coverage) are handled one should rather aim for using LineCoverageGoals instead.
| non_branch_fitness_functions: OrderedSet[ff.FitnessFunction] = OrderedSet() | ||
|
|
||
| for fit in fitness_functions: | ||
| assert isinstance(fit, bg.BranchCoverageTestFitness) |
There was a problem hiding this comment.
In the current implementation, DynaMOSA will not work if one fitness_functions is not BranchCoverageTestFitness. If this stays like this, we should still ensure that at least one of the fitness_functions is a BranchCoverageTestFitness.
| self._current_goals: OrderedSet[ff.FitnessFunction] = OrderedSet(self._graph.root_branches) | ||
|
|
||
| # Store non-branch goals separately (DO NOT activate yet) | ||
| self._non_branch_goals: OrderedSet[ff.FitnessFunction] = non_branch_fitness_functions |
There was a problem hiding this comment.
The name might cause confusion with CodeObjectGoals which are also "non-branch" goals but might belong to the self._current_goals.
If the logic stays like this, I am fine with this naming, but add a respective comment on what's the difference.
| # Add non-branch goals ONLY after all branch goals are covered | ||
| if len(self._archive.uncovered_goals) == 0: | ||
| added = False | ||
| for goal in self._non_branch_goals: | ||
| if goal not in self._current_goals: | ||
| self._current_goals.add(goal) | ||
| added = True | ||
|
|
||
| if added: | ||
| self._archive.add_goals(self._current_goals) # type: ignore[arg-type] |
There was a problem hiding this comment.
For simplicity, let's assume the second FitnessFunction is a LineCoverageTestFitness function.
First, such goals should probably be encoded as LineCoverageGoals.
Second, we might already be able to cover such goals before all branches are covered.
There was a problem hiding this comment.
Unit tests with heavy mocking are great to test some behaviour of your code in isolation. In this case it is tested, that initially "non-branch" goals are not active, which makes sense if it is intended as it is in this case.
However, this does not test other properties of the algorithm, such as what happens once all branch goals are covered.
Even if that is also covered with a unit test with heavy mocking, it is still not tested that the behaviour is the same for non-mocked stuff. In general, using a simple non-mocked example with a real archive, real goals and a real subject is preferrable here.
Even if all of that is added, I would still not be convinced that now DynaMOSA + LineCoverage works. This must be tested with an integration test.
|
Hi @LuKrO2011, Thank you for the detailed feedback — I really appreciate the time and clarity. I understand now that my current approach of introducing separate "non-branch" goals does not align well with the existing design of Pynguin. Your suggestion to instead work with LineCoverageGoals makes sense, and I see that it would integrate more naturally with the architecture. I also acknowledge that my current tests are too limited and rely heavily on mocking. I will work on improving this by:
Before proceeding with a redesign, I wanted to confirm: Thanks again for your guidance — this has been very helpful for my understanding. Best regards, |
This PR extends DynaMOSA to support coverage goals beyond branch coverage, such as line coverage.
Changes:
All existing tests pass, and no regressions were introduced.