Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Contribution
This PR fixes the FunctionFinder's problem so that it finds test names correctly for test suites.
Bug description
We use stretchr's testify suite in our go projects, so the test cases in our projects are like the example below:
The bug is when FunctionFinder scans test files to find all testName -> testFilePath mappings, it finds the wrong function names. For example, when scans the code above, the FunctionFinder thinks the test name is
TestSuite) TestExample
, but the correct function name isTestExample
.In later step, the GoJunitParser finds function names in the xml file. Then GoJunitParser uses the function name
TestExample
to find thefilePath
in the mapping that FunctionFinder provided. Due to the FunctionFinder found the wrong function name, so the GoJunitParser findsfilePath
to benull
. Thisnull
breaks the GoTestReportSaver in line 47:We currently work around this issue by renaming our suites to be
ExampleSuite
so that it doesn't include theTest
keyword. However it would be much better to get this problem fixed so that we can still use genericTestSuite
names.Steps to Reproduce
TestSuite
p.s (Only check test metric is enough, since coverage and linter metrics have no problems)
Content of your sonar-project.properties
All default settings
Versions
Server: 6.5
Sonar-Scanner: 3.0.3.778-macosx
Go version: 1.8.3
OS: macOS Sierra 10.12.6
gometalinter: 1.2.1