Skip to content

Exclude mock files from coverage reporting

Tomasz Maczukin requested to merge exclude-mocks-from-coverage-report into master

What does this MR do?

Exclude mock files from coverage reporting

Why was this MR needed?

Runner's codebase contains a lot of mock files. They are used only for tests and not for the production use.

Unfortunately, because the files are not named as *_test.go - to allow use the mocks in tests outside of the mock source package - they are counted to the coverage report.

We're using https://github.com/vektra/mockery to automatically generate mock files basing on interfaces. Mockery is creating mocks, that accept both scalar values as well as functions that accept mocked method argumets and returns mocked method result. However, we're mostly not using this mocking mechanism.

Finally this ends in a lot of mocks code being not covered in test, which decreases the overall coverage value. While we're totally not interested in having coverage for mocks!

This commit aims to remove all mocks from the coverage profile file, which should remove them from both percentage value calculation and the HTML/jUnit reports.

Are there points in the code the reviewer needs to double check?

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Added tests for this feature/bug
  • In case of conflicts with master - branch was rebased

What are the relevant issue numbers?

Merge request reports