Giter Site home page Giter Site logo

nunit-altcover-simple's Introduction

NUnit Unit Tests and AltCover coverage - A SonarQube Sonar Scanner for .NET Example

Unit testing using NUnit sample

This sample is part of the unit testing tutorial for creating applications with unit tests included. See that topic for detailed steps on the code for this sample.

Key features

This sample demonstrates creating a library and writing effective unit tests that validate the features in that library. The example provides a service that indicates whether a number is prime.

Restore and test

To run the tests, navigate to the PrimeService.Tests directory and type the following commands:

dotnet restore
dotnet test

dotnet restore restores the packages of both projects. dotnet test builds both projects and runs all of the configured tests.

Note: Starting with .NET Core 2.0 SDK, you don't have to run dotnet restore because it's run implicitly by all commands that require a restore to occur, such as dotnet new, dotnet build and dotnet run. It's still a valid command in certain scenarios where doing an explicit restore makes sense, such as continuous integration builds in Azure DevOps Services or in build systems that need to explicitly control the time at which the restore occurs.

TODO

write up instructions on this repo

> dotnet add package altcover --version 8.5.841
> BEGIN
> dotnet build
> nunit3-console.exe --result=NUnitResults.xml "PrimeService.Tests\bin\Debug\netcoreapp3.1\PrimeService.Tests.dll"
> dotnet test /p:AltCover=true
> END
# looks something like this
$ dotnet sonarscanner begin /k:"nunit-altcover" /d:"sonar.cs.opencover.reportsPaths=coverage.xml" /d:"sonar.login=<INSERT-USER-TOKEN" /d:"sonar.host.url=<INSERT-SQ-HOSTNAME>"
$ dotnet build ./unit-testing-using-nunit.sln
# can only run nunit3-console on windows...
$ nunit3-console.exe --result=NUnitResults.xml "PrimeService.Tests\bin\Debug\netcoreapp3.1\PrimeService.Tests.dll"
$ dotnet test /p:AltCover=true
$ dotnet sonarscanner end /d:"sonar.login=<INSERT-USER-TOKEN>"

nunit-altcover-simple's People

Contributors

joe-tingsanchali-sonarsource avatar

Watchers

 avatar

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.