Note: This guide assumes you have .NET Core installed.
-
Create a new project folder for the code.
(Assuming the project is named
new_kata
)dotnet new xunit -o new_kata cd new_kata rm .\UnitTest1.cs
-
Inside the project folder (
new_kata
), create a test file (TestArithmetic.cs
) with the following content:using System; using Xunit; namespace new_kata { public class TestArithmetic { [Fact] public void TestThat1Plus2Is3() { Assert.Equal(3, Arithmetic.Add(1, 2)); } } }
-
Inside the project folder (
new_kata
), create the implementation file (Arithmetic.cs
) with the following content:namespace new_kata { public static class Arithmetic { public static int Add(int x, int y) => x + y; } }
-
Run the test.
dotnet test
You should see this:
Starting test execution, please wait... Total tests: 1. Passed: 1. Failed: 0. Skipped: 0. Test Run Successful.
Checkout the C# Guide to know more about the language.