-
Notifications
You must be signed in to change notification settings - Fork 392
226 teamcity support #227
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
Merged
tonerdo
merged 8 commits into
coverlet-coverage:master
from
Reptarsrage:226_teamcity_support
Nov 13, 2018
Merged
226 teamcity support #227
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1542cf6
Added TeamCityOutput command line flag for printing TeamCity coverage…
Reptarsrage 6956f00
Added unit tests for TeamCityServiceMessageWriterTests
Reptarsrage dab248f
README updates
Reptarsrage 0eb8ce4
Added teamcity reporter
obtuse-whoosh 5e4566e
Removing teamcity output command line param
obtuse-whoosh d1c56cf
README updates
obtuse-whoosh d66eaab
Changed UseConsoleOutput boolean to ReporterOutputType enum
obtuse-whoosh fbd01ad
Merging TeamCityServiceMessageWriter with TeamCityReporter
obtuse-whoosh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| using Coverlet.Core; | ||
| using Coverlet.Core.Reporters; | ||
| using System.Text; | ||
|
|
||
| namespace coverlet.core.Reporters | ||
| { | ||
| public class TeamCityReporter : IReporter | ||
| { | ||
| public bool UseConsoleOutput => true; | ||
|
|
||
| public string Format => "teamcity"; | ||
|
|
||
| public string Extension => null; | ||
|
|
||
| public string Report(CoverageResult result) | ||
| { | ||
| // Calculate coverage | ||
| var summary = new CoverageSummary(); | ||
| var overallLineCoverage = summary.CalculateLineCoverage(result.Modules); | ||
| var overallBranchCoverage = summary.CalculateBranchCoverage(result.Modules); | ||
| var overallMethodCoverage = summary.CalculateMethodCoverage(result.Modules); | ||
|
|
||
| // Report coverage | ||
| var stringBuilder = new StringBuilder(); | ||
| var teamCityServiceMessageWriter = new TeamCityServiceMessageWriter(s => stringBuilder.AppendLine(s)); | ||
| teamCityServiceMessageWriter.OutputLineCoverage(overallLineCoverage); | ||
| teamCityServiceMessageWriter.OutputBranchCoverage(overallBranchCoverage); | ||
| teamCityServiceMessageWriter.OutputMethodCoverage(overallMethodCoverage); | ||
|
|
||
| // Return a placeholder | ||
| return stringBuilder.ToString(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| using Coverlet.Core; | ||
| using System; | ||
|
|
||
| namespace coverlet.core | ||
| { | ||
| public class TeamCityServiceMessageWriter | ||
Reptarsrage marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| private readonly Action<string> _writer; | ||
|
|
||
| public TeamCityServiceMessageWriter(Action<string> writer) | ||
| { | ||
| _writer = writer; | ||
| } | ||
|
|
||
| public void OutputLineCoverage(CoverageDetails coverageDetails) | ||
| { | ||
| // The total number of lines | ||
| OutputTeamCityServiceMessage("CodeCoverageL", coverageDetails.Total); | ||
|
|
||
| // The number of covered lines | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsLCovered", coverageDetails.Covered); | ||
|
|
||
| // Line-level code coverage | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsLTotal", coverageDetails.Percent * 100); | ||
| } | ||
|
|
||
| public void OutputBranchCoverage(CoverageDetails coverageDetails) | ||
| { | ||
| // The total number of branches | ||
| OutputTeamCityServiceMessage("CodeCoverageR", coverageDetails.Total); | ||
|
|
||
| // The number of covered branches | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsRCovered", coverageDetails.Covered); | ||
|
|
||
| // Branch-level code coverage | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsRTotal", coverageDetails.Percent * 100); | ||
| } | ||
|
|
||
| public void OutputClassCoverage(CoverageDetails coverageDetails) | ||
| { | ||
| // The total number of classes | ||
| OutputTeamCityServiceMessage("CodeCoverageC", coverageDetails.Total); | ||
|
|
||
| // The number of covered classes | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsCCovered", coverageDetails.Covered); | ||
|
|
||
| // Class-level code coverage | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsCTotal", coverageDetails.Percent * 100); | ||
| } | ||
|
|
||
| public void OutputMethodCoverage(CoverageDetails coverageDetails) | ||
| { | ||
| // The total number of methods | ||
| OutputTeamCityServiceMessage("CodeCoverageM", coverageDetails.Total); | ||
|
|
||
| // The number of covered methods | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsMCovered", coverageDetails.Covered); | ||
|
|
||
| // Method-level code coverage | ||
| OutputTeamCityServiceMessage("CodeCoverageAbsMTotal", coverageDetails.Percent * 100); | ||
| } | ||
|
|
||
| private void OutputTeamCityServiceMessage(string key, object value) | ||
| { | ||
| _writer?.Invoke($"##teamcity[buildStatisticValue key='{key}' value='{value}']"); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.