vs code dotnet run TERMINAL issue

NAXSIS 1 Reputation point
2022-03-18T09:41:54.917+00:00

the question is really simple, i'll made a example code space here and you can give answered , Thanks.

vs code ( latest ver )


Program.cs ( in it )
using System;

namespace App
{
class Program
{
static void main(string[] args)
{
Console.Writeline("Main");
}

static void TEST()
{
Console.WriteLine("TEST");
}
}
}

------------------- End of Program.cs File

----------------- Terminal operations

not : For making run the app ( writin in C# ) , Simply do the command of;

username\app> dotnet run

and the result is;
"
Main
"

We okay with that.

WHAT I WANT TO DO IS

how to RUN TEST Method in terminal like;

dotnet run TEST() kinda

Developer technologies .NET .NET CLI
Developer technologies C#
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2022-03-21T01:51:00.32+00:00

    Simply issue dotnet restore, dotnet run

    184992-f1.png


  2. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-03-21T16:37:37.303+00:00

    in dotnet you create a separate test project. you write your unit tests in this test project. you run the tests with the dotnet test command

    to create unit test, create a new class lib. add the NuGet Package for the unit test platform of choice. add a project reference to the project to test. write some unit tests. then run the units test with dotnet test

    you can create a solution file (dotnet sln) for both projects, and run the test on the solution. this will build both projects first.

    see:

    https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.