Skip to content

KubeRocketCI/template-node-autotests-empty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

.NET Autotest Project Template (KubeRocketCI)

This repository is a template for creating .NET API autotest components as part of the KubeRocketCI platform solution.

Project Overview

  • Designed for API contract and integration testing using .NET and xUnit/NUnit/MSTest.
  • Intended for use in CI/CD deploy pipelines and local development.
  • Template includes: README.md, .gitignore, Makefile.
  1. Create a solution file (if not present):

    dotnet new sln -n dotnet-autotests
  2. Create a test project (if not present):

    dotnet new xunit -n ApiContractTests -o ApiContractTests
    dotnet sln add ApiContractTests/ApiContractTests.csproj

    You can use xunit, nunit, or mstest as needed.

  3. Add required NuGet packages to your test project:

    dotnet add ApiContractTests/ApiContractTests.csproj package RestAssured.Net --version 4.10.0
    dotnet add ApiContractTests/ApiContractTests.csproj package NUnit --version 3.14.0
    dotnet add ApiContractTests/ApiContractTests.csproj package Microsoft.NET.Test.Sdk --version 17.9.0
    dotnet add ApiContractTests/ApiContractTests.csproj package NUnit3TestAdapter --version 4.5.0

    Add other dependencies as needed for your API testing.

  4. Add your tests to the ApiContractTests/Controllers/ directory. For example, create ApiContractTests/Controllers/HelloControllerTests.cs:

using NUnit.Framework;
using static RestAssured.Dsl;
using NHamcrest;

namespace ApiContractTests.Controllers
{
	[TestFixture]
	public class HelloControllerTests
	{
		private const string BaseUrl = "https://restful-api-run0-team0-backend-dev.development.krci-dev.cloudmentor.academy";

		[Test]
		public void Hello_ShouldReturn200AndString()
		{
			Given()
			.When()
				.Get(BaseUrl + "/api/hello")
			.Then()
				.StatusCode(200)
				.And()
				.Body(NHamcrest.Is.Not(NHamcrest.Is.Null()));
		}
	}
}
  1. Restore dependencies:

    dotnet restore
  2. Build the solution:

    dotnet build
  3. Run tests locally:

    dotnet test

CI/CD Usage

  • In CI/CD pipelines, the Makefile will call these .NET commands. If your test workflow requires different commands, update the Makefile accordingly to match your test setup.
  • The make commands are used in deploy pipelines (see Makefile).
  • make e2e will restore, build, and run all tests.

Recommendations

  • Use xUnit, NUnit, or MSTest for .NET API testing.
  • Organize tests by endpoint/resource.
  • Keep tests clear, maintainable, and aligned with your OpenAPI spec.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published