Skip to content

Commit

Permalink
Merge pull request #312 from MichaelChampagne/add_skipped_column_html…
Browse files Browse the repository at this point in the history
…_report

Add skipped column in html report
  • Loading branch information
boxed authored Apr 4, 2024
2 parents d598ea7 + 3483190 commit 69cf6ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions mutmut/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def create_html_report(dict_synonyms):

index_file.write('Killed %s out of %s mutants' % (len([x for x in mutants if x.status == OK_KILLED]), len(mutants)))

index_file.write('<table><thead><tr><th>File</th><th>Total</th><th>Killed</th><th>% killed</th><th>Survived</th></thead>')
index_file.write('<table><thead><tr><th>File</th><th>Total</th><th>Skipped</th><th>Killed</th><th>% killed</th><th>Survived</th></thead>')

for filename, mutants in groupby(mutants, key=lambda x: x.line.sourcefile.filename):
report_filename = join('html', filename)
Expand All @@ -293,10 +293,11 @@ def create_html_report(dict_synonyms):
killed = len(mutants_by_status[OK_KILLED])
f.write('Killed %s out of %s mutants' % (killed, len(mutants)))

index_file.write('<tr><td><a href="%s.html">%s</a></td><td>%s</td><td>%s</td><td>%.2f</td><td>%s</td>' % (
index_file.write('<tr><td><a href="%s.html">%s</a></td><td>%s</td><td>%s</td><td>%s</td><td>%.2f</td><td>%s</td>' % (
filename,
filename,
len(mutants),
len(mutants_by_status[SKIPPED]),
killed,
(killed / len(mutants) * 100),
len(mutants_by_status[BAD_SURVIVED]),
Expand Down Expand Up @@ -324,6 +325,11 @@ def print_diffs(status):
f.write('Mutants that made the test suite take longer, but otherwise seemed ok')
print_diffs(OK_SUSPICIOUS)

if mutants_by_status[SKIPPED]:
f.write('<h2>Skipped</h2>')
f.write('Mutants that were skipped')
print_diffs(SKIPPED)

f.write('</body></html>')

index_file.write('</table></body></html>')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,6 @@ def test_html_output(surviving_mutants_filesystem):
assert f.read() == (
'<h1>Mutation testing report</h1>'
'Killed 0 out of 2 mutants'
'<table><thead><tr><th>File</th><th>Total</th><th>Killed</th><th>% killed</th><th>Survived</th></thead>'
'<tr><td><a href="foo.py.html">foo.py</a></td><td>2</td><td>0</td><td>0.00</td><td>2</td>'
'<table><thead><tr><th>File</th><th>Total</th><th>Skipped</th><th>Killed</th><th>% killed</th><th>Survived</th></thead>'
'<tr><td><a href="foo.py.html">foo.py</a></td><td>2</td><td>0</td><td>0</td><td>0.00</td><td>2</td>'
'</table></body></html>')

0 comments on commit 69cf6ad

Please sign in to comment.