Running Unit Tests in VS Code for .NET Core 2.0

preview_player
Показать описание
In this episode, I look at how to create a custom task in Visual Studio code to run unit tests with NUnit and dotnet test. I bind that task to a custom keyboard shortcut to provide a quick and easy way to kick off unit tests while writing code.

If you're following along directly, you'll want to install the libraries I show in the demo:
- NUnit
- NUnit Console
- NUnit3TestAdapter
- Microsoft.NET.Test.Sdk

See this page for instructions on installing NuGet from the console.

NUnit GitHub repo:

Installation guide from the NUnit docs:

If you have any questions or requests for future episodes, leave them in the comments below!

GitHub repo with code from this video:
Рекомендации по теме
Комментарии
Автор

great tutorial!
Not as simple as having Resharper in VS but still impressive!
Thanks!

Vivalavidapool
Автор

I have a project where the Unit Test were done with MSTest, Do you happen to know, how to run this Unit test project in Visual Studio Code? Thanks in advance, great video by the way.

danyarias
Автор

Hey Wes, what's the color scheme that you're using here?

ThomasBrown
Автор

Why didn't view Console.WriteLine's message in terminal log ?

attilaturkkan
Автор

Hello, Wes! Could you please help me?) I have next issue: tasks.json is located in root folder, but my .csproj file for tests is located in 'root folder' -> test -> ConsoleApp1Tests.
So I have changed 'command' key value in tasks.json file and now it has next format: "command": "dotnet test
All work fine, but this solution not dynamic and adaptive I think : )
Do you have any ideas?

rvrby
Автор

is there something to run the specific tests from the specific class file. For Example, TestClass1.cs file has Test1, Test2....Test10 test scripts and now I want to run select multiple test, say Test3, Test5 and Test8 to be run then what I can do. Currently I can't select multiple tests for run. Either single or all tests

joshibhushan
Автор

Hi Wes. I'm struggling on how best to structure my project in VSCode when it comes to Source, Tests, and GitHub. Thought about having a single repo with a /src /tests with a .csproj file in each; doesn't seem like VSCode likes that. Could have two repos but that seems like overkill. Thoughts on how to best structure projects in VSCode when it comes to having the source, the tests, and GitHub?

RandySForbes
Автор

Hi good sir, can you install specflow on MacOS and use VSCode? I cant find any instructions anywhere to say that you can ?

usmaniqbal
Автор

Hi Wes,

How to create the test result report in Visual studio code, as in you have testresult.xml file, so user will be able to open the file and see which case is passed or failed.

robinmalhotra
Автор

hello, how can I create unit test for c++ in visual studio code?

thiagocavalcante
Автор

I'm new to .NET, but have you considered using `nodemon -w *.cs -x "dotnet test"` to run your tests on file changes?

philmod
Автор

Hi Wes, I've really, really appreciated your tutorials as well as your technology choices. Being new to unit testing, I'm curious as to whether you'd still pick NUnit over xUnit today? Coming in from ground zero, I'm getting the impression xUnit would be the better choice for a new project.

brianwells
Автор

Gettin error "warning NU1701: Package 'NUnit3TestAdapter 3.8.0' was restored using '.NETFramework, Version=v4.6.1'
instead of the project target framework '.NETStandard, Version=v2.0'. This package may not be fully compatible with your project."

ChandraSomalingam
Автор

thank you Wes for that, its helpfull.

Damian__
Автор

hey, Wes. Are you still with us? We didn't get any Friday video.

lightknight
visit shbcf.ru