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

Coverage on custom functions tests #128

Open
pfrayer opened this issue Aug 21, 2024 · 1 comment
Open

Coverage on custom functions tests #128

pfrayer opened this issue Aug 21, 2024 · 1 comment
Labels

Comments

@pfrayer
Copy link

pfrayer commented Aug 21, 2024

Describe the Bug

On a module, I have tests about custom functions present in this module. The tests work well, but the coverage don't detect it and stays at 0%.

My module structure is classic:

lib
└── puppet
    └── functions                      # my custom functions
    	├── bar.rb
    	└── foo.rb
spec
├── classes
└── functions                          # the related tests
	├── bar_spec.rb
	└── foo_spec.rb
templates
└── ...
files
└── ...
manifests
└── ...

rspec output:

$ rspec
Run options: exclude {:bolt=>true}
.................

Coverage Report:

Total resources:   0
Touched resources: 0
Resource coverage: 100.00%

Finished in 3.23 seconds (files took 1.57 seconds to load)
148 examples, 0 failures

Expected Behavior

rspec coverage report's resources should not be 0. Am I missing something ?

Environment

rspec (3.13.0)
rspec-core (3.13.0)
rspec-expectations (3.13.1)
rspec-github (2.4.0)
rspec-mocks (3.13.1)
rspec-puppet (4.0.2)
rspec-puppet-facts (5.1.0)
rspec-support (3.13.1)

spec_helper.rb uses a classic conf:

RSpec.configure do |c|
  c.default_facts = default_facts
  c.before :each do
    Puppet.settings[:strict] = :warning
    Puppet.settings[:strict_variables] = true
  end
  c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
  c.after(:suite) do
    RSpec::Puppet::Coverage.report!
  end

Additional Context

In this module I only have tests about custom functions, other part of the module aren't tested yet

@pfrayer pfrayer added the bug label Aug 21, 2024
@jordanbreen28
Copy link

hey @pfrayer thanks for raising this. We've been looking into this abit, and we believe that the test coverage will only include resources declared in your puppet classes. We agree it would be nice to include custom function coverage, but are unable to commit to this just yet. We'll leave this open for now incase anyone feels like taking the task on.

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

No branches or pull requests

2 participants