![]() NET projects and report it back to our GitHub project in a badge. Today we learned how to use code coverage on our. We can see the final result on our GitHub front page for this project. Note that our code coverage is 100% in this project because it is so simple – this is not a typical project from that perspective.Īt the bottom of this page, we can generate a badge for our readme.md page on GitHub. The screenshot below only shows the summary, but you are able to dive in for lots of individual details if needed. The project page for “SamsFeatureFlags” will begin to populate with code coverage information. Next we push our changes to the repo, start and merge the pull request and have the actions run. After authorization, we could then browse our list of repositories and enable our Feature Flags project: Opening coveralls.io for the first time, we will need to create an account, we used our GitHub account. ![]() Now we can configure coveralls.io and generate a badge for our GitHub repo. name: Publish coverage report to coveralls.io uses: with: github-token: $ path-to-lcov: FeatureFlags/FeatureFlags.Tests/TestResults/ All we need to customize here is the location of the, which will be generated in the “TestResults” folder we specified above. Then we add a new action to upload the code coverage information to coveralls.io. Run: dotnet test FeatureFlags/FeatureFlags.Tests/ /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov We can see this complete dotnet test command on line 54 of our Feature Flags Action, or just the task below - name: Run automated unit and integration tests p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov Adding to dotnet test, we add these three parameters to collect the code coverage, output the results in the “TestResults” folder, in the format “lcov”. Next we edit our pipeline, to generate the test output. ![]() First step, in our Visual Studio project, we need to add the “ coverlet.msbuild” NuGet package to our test project. However, it’s currently not possible without using a third party service, coveralls.io. After some wrangling, we have found a solution. This was a surprisingly difficult goal to achieve. Badges are a fun way to introduce gamification, as well as help communicate and reinforce the idea our open source projects are following best testing practices. NET code coverage in GitHub, with a badge to display the code coverage.
0 Comments
Leave a Reply. |