May 18, 2022

Blog @ Munaf Sheikh

Latest news from tech-feeds around the world.

Using Remote Testing With .NET Core

Great post from our friends at Source link

It’s no secret that .NET Core is becoming increasingly popular. As a result, more developers are creating .NET applications on Windows and then deploying them on Linux. This trend is understandable, as there are many differences between these platforms. 

For this reason, it’s important to run your debugging tests directly on Linux to avoid errors in production. But using Docker to debug your application on Linux can be tricky and time-consuming, and setting up a remote SSH connection can be challenging if you haven’t done it before.

Cross-Platform Development Is Hard

Until now, remote debugging on Linux has given you some pretty crummy options. You could use SSH to forward ports or try to virtualize the WSL and run it in a VM on your desktop. Neither is a great option, and neither is particularly efficient. Remote testing enables Visual Studio 2022 to run and debug tests on remote machines, across different operating systems. This capability is great for cross-platform developers who deploy code to multiple different target environments such as different Windows or Linux operating systems.

Get Started With Remote Testing

To get feedback from your Linux tests, normally you’ll have to push the changes to your project on a continuous integration server. With this feature, you can do that right from Visual Studio. Now, you can connect your Test Explorer directly to a remote Linux system, so that you can get faster feedback on your builds from Linux tests. Pre-requisites for remote testing as stated by Microsoft are Visual Studio 2022 Update 17.0 Preview 3 or later and is currently available only for .NET tests targeting Ubuntu, Windows, or Debian images in the remote environment.

Set Up the Remote Testing Environment

Environments are specified using testenvironments.json the root of your solution. The JSON file structure follows the schema described here:

"version": "1",
"environments": [
    "name": "linux dotnet-core-sdk-3.1",
    "type": "docker",
    "dockerImage": ""

Targeting Multiple Distributions

If you have an application designed to run across multiple Linux distributions, you can use multiple launch profiles to test it quickly on each distribution. For example, if you are testing your console app on Debian, Ubuntu 18.04/20.04, you can use the launch profiles mentioned below:

"WSL 2 : Debian": {
    "commandName": "WSL2",
    "distributionName": "Debian"
"WSL 2 : Ubuntu 18.04": {
    "commandName": "WSL2",
    "distributionName": "Ubuntu-18.04"
"WSL 2 : Ubuntu 20.04": {
    "commandName": "WSL2",
    "distributionName": "Ubuntu-20.04"

Use the Test Explorer To Run and Debug Remote Tests

To run tests, use a drop-down in the Test Explorer toolbar. Right now, only one test environment can be active at a time. Once an environment is selected, tests are discovered and run in the new environment. You can configure your remote environment to fit your own preferences.

Future of Web?

As the two worlds of Linux and Windows continue to converge, it’s interesting to imagine what the future world of the web will be like. We are building some amazing tools and applications that are cross-platform and deliver the best of both worlds. 

Learn more about these tech stacks to help with your next production-grade web-dev project testing on all platforms you desire to deploy. 

#Remote #Testing #NET #Core