.NET Code Coverage for Continuous Integrationusing TeamCity and dotCover
-
Upload
maarten-balliauw -
Category
Technology
-
view
731 -
download
3
description
Transcript of .NET Code Coverage for Continuous Integrationusing TeamCity and dotCover
.NET Code Coverage for Continuous Integrationusing TeamCity and dotCoverMaarten BalliauwTechnical [email protected] @maartenballiauw
Who am I? Maarten Balliauw
Belgium (Antwerp)
Technical Evangelist, JetBrains
Focus on web ASP.NET MVC, Windows Azure, ... PHP, ...
Big passion: Cloud (Windows Azure)
Home brewer
http://blog.maartenballiauw.be
@maartenballiauw
Have a question? Use the Question Pane. We’ll try and answer as we go along.
Recording
Recording will start now….
Agenda Code coverage
dotCover
Code coverage during CI
Command line runner
TeamCity integration
TeamCity service messages
TeamCity Visual Studio plugin
Code Coverage
“Code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite.”
Wikipedia - http://en.wikipedia.org/wiki/Code_coverage
dem
o
Code CoverageUsing dotCover to capture Code Coverage
Holy grail? Code Coverage is just a tool Verify # of statements executed during a test run
100% coverage != 100% bug free / well-tested code It’s relatively easy to cover all lines of code It’s much harder to test them correctly Should we aim for 100%?
We should care about code coverage! Identify parts of code not covered by any type of test and reduce
chance of defects
dotCover Capture which statements have been executed (using profiler) During unit test During manual test
Display coverage percentage
Statement level coverage visualization
Hotspots to quickly identify parts that need testing
Filtering, exporting, ...
Navigate between code and test
Command line runner
dem
o
dotCover 101A quick look at dotCover
When to perform code coverage? Let’s counter that with a question: When to run unit tests?
On developer machine is always nice, but… Continuous Integration is our view of the truth Compile, Run tests, Code coverage, …
TeamCity JetBrains Continuous Integration Server Project Logical name/unit Build Configuration Something we want to run Build Steps Various steps we want to run (like compilation or unit tests, .NET, Java, deployment,
…) Build Execution log and artifacts of a build configuration after run
Integrated build step for running NUnit + code coverage using dotCover
dem
o
TeamCity 101A quick look at TeamCity
TeamCity Service Messages Test resuls from xUnit were reported using TeamCity Service Messages
http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-Reporting.NETCodeCoverageResults
##teamcity[testStarted name='testName' captureStandardOutput='<true/false>']##teamcity[testFinished name='testName' duration='<test_duration_in_milliseconds>']
We can report coverage using this technique as well!##teamcity[importData type='dotNetCoverage' tool='dotcover' path='coverage.xml'
Now all we need is way to run tests with coverage...
dotCover Command Line Runner dotcover.exe Create configuration (which executable, which assemblies, …) Run dotcover.exe with that configuration Export to XML, HTML, …
dem
odotCovercommand line runnerUsing the command line runner
dem
o
TeamCity pluginfor Visual StudioMaking the story complete
Conclusion Code coverage
dotCover
Code coverage during CI
Command line runner
TeamCity integration
TeamCity service messages
Visual Studio Plugin
Questions
Leading by example
Resources Try dotCover now! http://www.jetbrains.com/dotcover
Tutorials Getting started
http://confluence.jetbrains.com/display/NETCOM/Getting+Started+with+dotCover
Command line runner http://confluence.jetbrains.com/display/NETCOM/How+to+Run+Code+Coverage+from+Command+Line+in+dotCover
dotCover in TeamCity http://confluence.jetbrains.com/display/NETCOM/How+to+Run+Code+Coverage+with+dotCover+in+TeamCity
TeamCity Service Messageshttp://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-Reporting.NETCodeCoverageResults
More info
Home
FeedbackVideosBlog
http://jetbrains.com/dotcover
[email protected]://youtrack.jetbrains.com/
issues/DCVRhttp://www.youtube.com/
jetbrainstv.NET Tools Channelhttp://blog.jetbrains.com/dotnet
Thank you for joining us!
Want to learn more?
Follow @dotcover on Twitter
to learn product tips and register for upcoming
webinars