Use SonarXmlCheckVerifier
:
SonarXmlCheckVerifier.verifyIssueOnFile("file.xml", new FileTestCheck(), "File level message", 1, 2);
You can use comments notation from test-commons to assert issues information.
SonarXmlCheckVerifier.verifyIssues("checkTestFile.xml", testCheck);
❗ Tested XML files should be in directory
src/test/java/resources/checks/<CheckClassName>
Copyright 2009-2023 SonarSource. Licensed under the GNU Lesser General Public License, Version 3.0