forked from simplecov-ruby/simplecov
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_unit_groups_and_filters_complex.feature
35 lines (30 loc) · 1.25 KB
/
test_unit_groups_and_filters_complex.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@test_unit
Feature: Sophisticated grouping and filtering on Test/Unit
Defining groups and filters can be done by passing blocks or strings.
Blocks get each SimpleCov::SourceFile instance passed an can use arbitrary
and potentially weird conditions to remove files from the report or add them
to specific groups.
Scenario:
Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
add_group 'By block' do |src_file|
src_file.filename =~ /MaGiC/i
end
add_group 'By string', 'project/meta_magic'
add_filter 'faked_project.rb'
# Remove all files that include "describe" in their source
add_filter {|src_file| src_file.lines.any? {|line| line.src =~ /TestCase/ } }
add_filter {|src_file| src_file.covered_percent < 100 }
end
"""
When I open the coverage report generated with `bundle exec rake test`
Then I should see the groups:
| name | coverage | files |
| All Files | 100.0% | 1 |
| By block | 100.0% | 1 |
| By string | 100.0% | 1 |
And I should see the source files:
| name | coverage |
| lib/faked_project/meta_magic.rb | 100.0 % |