jstemmer / go-junit-report

Convert Go test output to JUnit XML
MIT License
764 stars 222 forks source link

Result from test no properly converter #118

Closed bb-dsa closed 2 years ago

bb-dsa commented 3 years ago

I'm executing the test for my Go application in the following way: go test -coverprofile=.build/coverage.txt -covermode count ./... 2>&1 | go-junit-report > .build/test-report.xml

Without piping it to go-junit-report the following is printed on the console:

go: downloading github.com/gorilla/websocket v1.4.1
?       foo.bar/server/internal/nanomsg       [no test files]
ok      foo.bar/server/internal/protobuf      0.007s  coverage: 17.6% of statements
?       foo.bar/server/internal/query [no test files]

However, the result XML file generated by go-junit-report states that no tests have been executed:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
        <testsuite tests="0" failures="0" time="0.028" name="foo.bar/server/internal/protobuf">
                <properties>
                        <property name="go.version" value="go1.16"></property>
                        <property name="coverage.statements.pct" value="17.6"></property>        
                </properties>
        </testsuite>
</testsuites>

What do I have to change to get the expected output?

jstemmer commented 2 years ago

You should add the -v flag to the go test command, e.g. go test -v -coverprofile=...etc. Without this flag no output is generated for passing tests, and go-junit-report won't be able to include them in the report.