Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgDangl committed May 29, 2018
2 parents 885e342 + a855318 commit 0ea6438
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to **CoberturaConverter** are documented here.

## v1.1.3:
- Bugfix: dotCover to Cobertura reported covered statements for total statements (see #2)

## v1.1.2:
- Bugfix: dotCover failed when method did contain double colons `::` (see #1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public CoberturaReport ConvertToCobertura()

_coberturaReport.Complexity = 0;

_coberturaReport.LinesValid = _report.CoveredStatements;
_coberturaReport.LinesValid = _report.TotalStatements;
_coberturaReport.LineRate = _report.CoveragePercent * 0.01m;
_coberturaReport.LinesCovered = _report.CoveredStatements;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Linq;
using System.Xml.Linq;
using Xunit;

namespace CoberturaConverter.Core.Tests.Regression
{
public class DotCoverTotalLinesValidAndCovered
{
// Issue #2 on GitHub reported the error that the CoberturaReport
// used "CoveredStatements" instead of "TotalStatements" for the
// "LinesValid" property in the destination Cobertura report

[Fact]
public void UseTotalStatementsForLinesValidInCobertura()
{
using (var xmlStream = TestFilesFactory.GetTestFileStream(DotCoverConverter.Core.Tests.TestFile.DanglCommonDotCover))
{
using (var convertedCoberturaStream = CoberturaConverter.ConvertDotCoverToCobertura(xmlStream))
{
var coberturaXml = XDocument.Load(convertedCoberturaStream);

var actualLinesValid = coberturaXml.Descendants()
.Where(d => d.Name.LocalName == "coverage")
.Select(d => d.Attribute("lines-valid"))
.Select(a => a.Value)
.Single();

var expected = "500"; // 500 TotalStatements in dotCover report
Assert.Equal(expected, actualLinesValid);
}
}
}

[Fact]
public void UseCoveredStatementsForLinesCoveredInCobertura()
{
using (var xmlStream = TestFilesFactory.GetTestFileStream(DotCoverConverter.Core.Tests.TestFile.DanglCommonDotCover))
{
using (var convertedCoberturaStream = CoberturaConverter.ConvertDotCoverToCobertura(xmlStream))
{
var coberturaXml = XDocument.Load(convertedCoberturaStream);

var actualLinesCovered = coberturaXml.Descendants()
.Where(d => d.Name.LocalName == "coverage")
.Select(d => d.Attribute("lines-covered"))
.Select(a => a.Value)
.Single();

var expected = "492"; // 500 TotalStatements in dotCover report
Assert.Equal(expected, actualLinesCovered);
}
}
}
}
}

0 comments on commit 0ea6438

Please sign in to comment.