Proposal to investigate: Increase test coverage using integration tests #1829
Labels
conclusion: resolved
Issue was resolved
topic: infrastructure
Related to project infrastructure
type: enhancement
Proposed improvement
Describe the request
Currently, the code coverage is calculated only on unit-test because go-lang offers this feature via
go test
command. For example, in ourgo:test
Taskfile script we usa a command line flag that can be summarized as:These flags produce a
coverage_unit.txt
file that is later sent to the codecov.In the integration tests, instead, we run directly a build of the
arduino-cli
, using theexecutils
library. in this case, just adding the-cover*
flags in thego test
commands actually would not add any coverage (except maybe for theexecutils
library).BTW a way to workaround this limitation exists, even if a bit convoluted, here's how:
go test
command offers a-c
flag that "compiles" the test instead of running it:go test
will do.go test ./internal/cli-runner/ --run=RunArduinoCLITest -coverpkg=./... -covermode=atomic -coverprofile=coverage_unit.txt -c -o arduino-cli-withcoverage
an executable calledarduino-cli-withcoverage
that will run thearduino-cli
as it was in a test but with the parameters we pass to it.arduino-cli-withcoverage
to run integration tests instead ofarduino-cli
and get the coverage from the integration tests!Now this is very theoretical, I can already see some obstacles:
Main
method (easy)RunArduinoCLITest
to make it digestible from the arduino-cli (medium)os.Exit
calls (hard)arduino-cli-withcoverage
will produce a differentcoverage.txt
, all thecoverage.txt
should be collected and merged together (medium)Anyway, given the difficulties above, IMHO it's still something worth considering if possible.
Describe the current behavior
No test coverage is reported from integration-tests.
Arduino CLI version
N/A
Operating system
N/A
Operating system version
N/A
Additional context
No response
Issue checklist
The text was updated successfully, but these errors were encountered: