.NET Code Coverage for Continuous Integrationusing TeamCity and dotCover
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

.NET Code Coverage for Continuous Integration using TeamCity and dotCover

  • 727 views
Uploaded on

How much of our code is being covered by our unit tests? Are there areas we are not testing? By capturing code coverage data during a test run, we can analyze which areas of our applications are......

How much of our code is being covered by our unit tests? Are there areas we are not testing? By capturing code coverage data during a test run, we can analyze which areas of our applications are well-tested and which ones require additional tests to be written. And where better to capture code coverage information than on our build server?
In this webinar we will use dotCover to collect code coverage information while running tests in our CI process. We will see how we can configure code coverage and how we can use the TeamCity Visual Studio plugin to download the coverage snapshot generated on the build server and inspect it using dotCover on a developer machine.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
727
On Slideshare
727
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. .NET Code Coverage for Continuous Integration using TeamCity and dotCover Maarten Balliauw Technical Evangelist maarten.balliauw@jetbrains.com @maartenballiauw
  • 2. 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
  • 3. Have a question? Use the Question Pane. We’ll try and answer as we go along.
  • 4. Recording Recording will start now….
  • 5. Agenda Code coverage dotCover Code coverage during CI Command line runner TeamCity integration TeamCity service messages TeamCity Visual Studio plugin
  • 6. 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
  • 7. demo Code Coverage Using dotCover to capture Code Coverage
  • 8. 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
  • 9. 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
  • 10. demo dotCover 101 A quick look at dotCover
  • 11. 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, …
  • 12. 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
  • 13. demo TeamCity 101 A quick look at TeamCity
  • 14. 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...
  • 15. dotCover Command Line Runner dotcover.exe Create configuration (which executable, which assemblies, …) Run dotcover.exe with that configuration Export to XML, HTML, …
  • 16. demo dotCover command line runner Using the command line runner
  • 17. demo TeamCity plugin for Visual Studio Making the story complete
  • 18. Conclusion Code coverage dotCover Code coverage during CI Command line runner TeamCity integration TeamCity service messages Visual Studio Plugin
  • 19. Questions Leading by example
  • 20. 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+dot Cover dotCover in TeamCity http://confluence.jetbrains.com/display/NETCOM/How+to+Run+Code+Coverage+with+dotCover+in+TeamCity TeamCity Service Messages http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwit hTeamCity-Reporting.NETCodeCoverageResults
  • 21. More info Home Feedback Videos Blog http://jetbrains.com/dotcover maarten.balliauw@jetbrains.com http://youtrack.jetbrains.com/issues/DCVR http://www.youtube.com/jetbrainstv .NET Tools Channel http://blog.jetbrains.com/dotnet
  • 22. Thank you for joining us! Want to learn more? Follow @dotcover on Twitter to learn product tips and register for upcoming webinars