NUnit.Extensions.Helpers
2.0.1
See the version list below for details.
dotnet add package NUnit.Extensions.Helpers --version 2.0.1
NuGet\Install-Package NUnit.Extensions.Helpers -Version 2.0.1
<PackageReference Include="NUnit.Extensions.Helpers" Version="2.0.1" />
<PackageVersion Include="NUnit.Extensions.Helpers" Version="2.0.1" />
<PackageReference Include="NUnit.Extensions.Helpers" />
paket add NUnit.Extensions.Helpers --version 2.0.1
#r "nuget: NUnit.Extensions.Helpers, 2.0.1"
#:package NUnit.Extensions.Helpers@2.0.1
#addin nuget:?package=NUnit.Extensions.Helpers&version=2.0.1
#tool nuget:?package=NUnit.Extensions.Helpers&version=2.0.1
NUnit.Extensions.Helpers
Helpers to generate NUnit tests
This is not an official NUnit package.
Install
Add the NuGet package NUnit.Extensions.Helpers to any project supporting .NET Standard 2.0 or higher.
> dotnet add package NUnit.Extensions.Helpers
Information
Usage
Constructor parameter null tests
Use the GenerateConstructorParameterNullTests attribute to define the SUT (class which should be tested) to generate constructor parameter tests for.
[GenerateConstructorParameterNullTests(typeof(Document))]
internal partial class DocumentTests
{
[Test]
public void Test1()
{
Assert.Pass();
}
}
If the SUT looks like
public class Document
{
private Stream _stream;
private IFileTester _fileTester;
private IOtherFilter _filter;
public Document(Stream myStream, IFileTester fileTester, IOtherFilter filter)
{
_stream = myStream ?? throw new ArgumentNullException(nameof(myStream));
_fileTester = fileTester ?? throw new ArgumentNullException(nameof(fileTester));
_filter = filter ?? throw new ArgumentNullException(nameof(filter));
}
}
following code will be generated:
partial class DocumentTests
{
[Test]
public void Throws_Exception_When_MyStream_Is_Null()
{
Action action = () => new Document(null, null, null);
action.ShouldThrow<ArgumentNullException>().ParamName.Should().Be("myStream");
}
[Test]
public void Throws_Exception_When_FileTester_Is_Null()
{
Action action = () => new Document(Mock.Of<System.IO.Stream>(), null, null);
action.ShouldThrow<ArgumentNullException>().ParamName.Should().Be("fileTester");
}
[Test]
public void Throws_Exception_When_Filter_Is_Null()
{
Action action = () => new Document(Mock.Of<System.IO.Stream>(), Mock.Of<Sample.IFileTester>(), null);
action.ShouldThrow<ArgumentNullException>().ParamName.Should().Be("filter");
}
}
Options
It's possible to generate a nested class with the AsNestedClass argument.
[GenerateConstructorParameterNullTests(typeof(Document), AsNestedClass = true)]
internal partial class TestWithNested
{
}
Web service tests
Use the WebServiceTester helper class. This class reads the OpenApi documentation and can execute arbitary tests.
[Test]
public async Task TestEndpointSecurity()
{
var tester = new WebServiceTester("swagger.json");
await tester.VerifySecuredEndpointsRequiresAuthentication(httpClient, CancellationToken.None);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Microsoft.OpenApi (>= 3.11.1)
- NUnit.Extensions.Helpers.Generators (>= 2.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.2 | 48 | 11/20/2026 |
| 2.0.1 | 50 | 11/20/2026 |
| 2.0.0 | 95 | 11/11/2026 |
| 1.3.4 | 157 | 7/2/2026 |
| 1.3.3 | 136 | 5/15/2026 |
| 1.3.2 | 465 | 11/18/2025 |
| 1.3.1 | 461 | 11/18/2025 |
| 1.3.0 | 477 | 11/18/2025 |
| 1.2.0 | 285 | 10/13/2024 |
| 1.1.1 | 238 | 10/13/2024 |
| 1.1.0 | 254 | 10/13/2024 |
| 1.0.4 | 262 | 9/11/2024 |
| 1.0.3 | 273 | 9/11/2024 |
| 1.0.2 | 250 | 9/11/2024 |
| 1.0.1 | 235 | 9/10/2024 |