Currently the reported ‘Must have assertion’ issues are set as False Positives
It works without error if the assert is in the TestMethod but we want the code to be maintainable and separated out into a common file - then we get the error as sonar is unable to identify the assertion.
I understand that for this rule then
cross-procedural / file analysis is only able to explore the body of test methods. Our sonar account manager says this was closed years ago - https://jira.sonarsource.com/browse/MMF-256 - was it related to this issue ?
Is there a fix for this in v10.4 or a planned future version ? Or a recommended work around perhaps ?
Thank you for bringing up this concern regarding the rule about test assertions in test files. You’re absolutely correct in pointing out the importance of cross-file analysis, particularly when assertions are modularized across different files.
At the moment, several rules within the JavaScript analyzer are confined to considering the scope of individual files when reporting issues. This, unfortunately, includes the rule related to test assertions. We acknowledge the limitation and are planning to introduce more advanced analysis capabilities throughout this year.
However, since we are only at the early stages of our plans, nothing has been decided yet regarding whether this would directly benefit the specific rule you mentioned. We are currently in the process of evaluating various options and their potential impacts.
In the meantime, the only viable workaround available would be to either disable the rule or mark the reported issues as false positives while awaiting further enhancements.