Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement coverage check #73

Open
bastelfreak opened this issue Mar 13, 2022 · 2 comments
Open

Implement coverage check #73

bastelfreak opened this issue Mar 13, 2022 · 2 comments

Comments

@bastelfreak
Copy link
Member

pdk-templates has an option to enforce a minimal rspec-puppet coverage. We currently have this:

RSpec.configure do |config|
# This completely disables Facter and uses a stubbed implementation. This is
# fine since we use use rspec-puppet-facts to set all facts. It gives
# complete isolation from the host system. It only works with Puppet 6.25+
# and 7.12+ and requires rspec-puppet 2.11.0+.
config.facter_implementation = 'rspec'
config.after(:suite) do
RSpec::Puppet::Coverage.report!
end
end

to enforce a coverage of 100 it would need to be:

RSpec.configure do |config|
  # This completely disables Facter and uses a stubbed implementation. This is
  # fine since we use use rspec-puppet-facts to set all facts. It gives
  # complete isolation from the host system. It only works with Puppet 6.25+
  # and 7.12+ and requires rspec-puppet 2.11.0+.
  config.facter_implementation = 'rspec'

  config.after(:suite) do
    RSpec::Puppet::Coverage.report!(100)
  end
end

@ekohl any ideas how we could make this configureable from a module?

@alexjfisher
Copy link
Member

I'm not sure they're useful. It doesn't check coverage of your manifests, just out of the resources that ended up in catalogs which ones had any tests associated. Whole classes might have 0 tests, but if those classes weren't included by any of the tests you do have, coverage might still show 100%. Meanwhile, there's a whole lot of busy work writing often pretty pointless lines of rspec just to make this go green.

@ekohl
Copy link
Member

ekohl commented Mar 14, 2022

I'm also not a fan of coverage enforcement. IMHO it doesn't give any guarantees about quality. Usually it's just playing with getting numbers, not really improving anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants