Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make test suite vary the coverage

  • Loading branch information...
commit 8d030129dab414d2c8595f15d6c85c0b84289b3b 1 parent 85edee1
Wes Morgan cap10morgan authored
8 test/fixtures/file_tr.html
View
@@ -1,7 +1,7 @@
<tr class="all_files">
<td class="left_align"><a href="#./app/controllers/sample_controller.rb">./app/controllers/sample_controller.rb</a></td>
- <td class='right_align'><tt>900</tt></td>
- <td class='right_align'><tt>600</tt></td>
- <td class="left_align"><tt class=''>50.00%</tt></td>
- <td class="left_align"><tt class=''>50.00%</tt></td>
+ <td class='right_align'><tt>33</tt></td>
+ <td class='right_align'><tt>30</tt></td>
+ <td class="left_align"><tt class=''>76.67%</tt></td>
+ <td class="left_align"><tt class=''>76.67%</tt></td>
</tr>
8 test/fixtures/totals_tr.html
View
@@ -1,7 +1,7 @@
<tr>
<td class="left_align">TOTAL</td>
- <td class='right_align'><tt>2700</tt></td>
- <td class='right_align'><tt>1800</tt></td>
- <td class="left_align"><tt class=''>50.00%</tt></td>
- <td class="left_align"><tt class='coverage_total'>50.00%</tt></td>
+ <td class='right_align'><tt>338</tt></td>
+ <td class='right_align'><tt>299</tt></td>
+ <td class="left_align"><tt class=''>70.25%</tt></td>
+ <td class="left_align"><tt class='coverage_total'>70.25%</tt></td>
</tr>
50 test/simplecov-rcov_test.rb
View
@@ -11,15 +11,19 @@ def test_format
# If you change it from 900, you'll need to edit the fixtures appropriately.
# The number should always be evenly divisible by 3 and the coverage percentage
# will always be 50%.
- source_lines_count = 900
+ # source_lines_count = 900
- fixtures = ['sample.rb', 'app/models/user.rb', 'app/controllers/sample_controller.rb']
+ # keys are fake source files, values are number of lines to generate for that file
+ # MAKE SURE these are all evenly divisible by 3
+ fixtures = { 'sample.rb' => 141, 'app/models/user.rb' => 165,
+ 'app/controllers/sample_controller.rb' => 33 }
@original_result = {}
fakeroot = '/fake'
- fixtures.each do |fixture|
- @original_result[File.join(fakeroot, fixture)] = generate_coverage_results(source_lines_count)
- fixture_source_lines = generate_source_lines(fixture, source_lines_count)
- File.stubs(:readlines).with(File.join(fakeroot, fixture)).returns(fixture_source_lines)
+ fixtures.each_pair do |fixture_file, num_lines|
+ @original_result[File.join(fakeroot, fixture_file)] =
+ generate_coverage_results(num_lines)
+ fixture_source_lines = generate_source_lines(fixture_file, num_lines)
+ File.stubs(:readlines).with(File.join(fakeroot, fixture_file)).returns(fixture_source_lines)
SimpleCov.stubs(:root).returns(fakeroot)
end
@@ -33,10 +37,38 @@ def test_format
def generate_coverage_results(num_lines)
result_types = [nil, 0, 1]
- each_result_count = num_lines / 3
results = []
- each_result_count.times do
- results += result_types
+ case num_lines
+ when 1..100
+ (num_lines*0.10).round.times do
+ results << result_types[0]
+ end
+ (num_lines*0.20).round.times do
+ results << result_types[1]
+ end
+ (num_lines*0.70).round.times do
+ results << result_types[2]
+ end
+ when 100..150
+ (num_lines*0.20).round.times do
+ results << result_types[0]
+ end
+ (num_lines*0.40).round.times do
+ results << result_types[1]
+ end
+ (num_lines*0.40).round.times do
+ results << result_types[2]
+ end
+ else
+ (num_lines*0.05).round.times do
+ results << result_types[0]
+ end
+ (num_lines*0.15).round.times do
+ results << result_types[1]
+ end
+ (num_lines*0.80).round.times do
+ results << result_types[2]
+ end
end
rand_results = []
results.count.times do
Please sign in to comment.
Something went wrong with that request. Please try again.