C# Bronze Badge Todo API + API Tests using NUnit Restsharp Simple TodoAPI created following the MSLearn article. Added an API test framework for the REST service endpoints using NUnit RestSharp plus FluentAssertions.
Nuget packages:
- RestSharp 110.2.0
- NUnit 3.13.3
- Newtonsoft.Json 13.0.3
- FluentAssertions 6.12.0
- NUnit.ConsoleRunner 3.17.0
Instructions:
-
Clone repository
-
Install nuget packages
-
Configure NUnit Console Runner
-
Get the NUnit Console Runner from this link. Make sure to use the
NUnit.Console-3.17.0.msi
-
You can specify the PATH to NUnit Console Runner in your machine:
1. Right-click on Windows icon and choose System. 2. Select Advanced system settings. 3. Select `Path` under User variables for User and click Edit. 4. Click New and add the path to the tools folder of NUnit Console Runner i.e. C:\Users\CarloCandoy\.nuget\packages\nunit.consolerunner\3.17.0\tools 5. Then click OK
-
-
Locate the folder where the Tests.dll is. i.e.
C:\Users\CarloCandoy\Desktop\c-sharp-bronze\TodoApi\Tests\bin\Debug\net8.0\Tests.dll
-
Run the tests by doing
nunit3-console.exe Path\To\Tests.dll
e.g.
nunit3-console.exe C:\Users\CarloCandoy\Desktop\c-sharp-bronze\TodoApi\Tests\bin\Debug\net8.0\Tests.dll
Or if you did not set the PATH, you can do:
Path\to\nunit3-console.exe Path\to\Tests.dll
example:
C:\Users\CarloCandoy\.nuget\packages\nunit.consolerunner\3.17.0\tools\nunit3-console.exe C:\Users\CarloCandoy\Desktop\c-sharp-bronze\TodoApi\Tests\bin\Debug\net8.0\Tests.dll
CLI Options
Description | Command | Example |
---|---|---|
Specify the specific TestFixture to run | --test=FILENAME |
nunit3-console.exe C:\Users\CarloCandoy\Desktop\c-sharp-bronze\TodoApi\Tests\bin\Debug\net8.0\Tests.dll --test=Tests.TestFixtures.EditTodoItemTests |
Run all the Tests | nunit3-console.exe Path\to\Tests.dll |
nunit3-console.exe C:\Users\CarloCandoy\Desktop\c-sharp-bronze\TodoApi\Tests\bin\Debug\net8.0\Tests.dll |