GithubHelp home page GithubHelp logo

objectcomparer's Introduction

ObjectComparer

Class library desgin to compare if two objects are identical.

Testing and coverage with xunit

Creating and running test is fairly easy with xunit. Generating a coverage report was a bit tricky. The next steps describe how I managed to get it working.

To generate the coverage file we need to install coverlet.msbuild. I was able to install the nuget using the nuget package manager but I noticed dotnet test commands where not working as expected. Based on the following Github Post I was able to get it working by uninstalling the nuget and executing the following command:

dotnet add package coverlet.msbuild

Using this aproach fixed the isues I was having. To generate a coverage file (coverage.json) use the following command:

dotnet test /p:CollectCoverage=true

To generate a more readable file (coverage.cobertura) based on the json previously generated use the following command:

dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura

This alone can be used to publish code coverage data to VSTS build results. After generating our .xml file we can generate a more visual report using the follwoing command:

reportgenerator "-reports:ObjectComparer.Test\coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:Html

In case you don't have report generator execute the following command:

dotnet tool install -g dotnet-reportgenerator-globaltool

Links:

Development:

https://stackoverflow.com/questions/506096/comparing-object-properties-in-c-sharp https://stackoverflow.com/questions/10454519/best-way-to-compare-two-complex-objects https://stackoverflow.com/questions/238555/how-do-i-get-the-value-of-memberinfo https://stackoverflow.com/questions/15921608/getting-the-type-of-a-memberinfo-with-reflection

Testing:

https://github.com/coverlet-coverage/coverlet https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-code-coverage?tabs=windows https://medium.com/bluekiri/code-coverage-in-vsts-with-xunit-coverlet-and-reportgenerator-be2a64cd9c2f

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.