Provides combinatorial test data for a test method written with xUnit and MSTest.
This library is designed to simplify the process of generating combinatorial test data for test methods. Combinatorial testing is a technique that involves testing all possible combinations of input values to ensure comprehensive test coverage.
There are 2 different NuGet packages for xUnit and MSTest. You can install the one that fits your testing framework.
- package for xUnit:
SolidCode.CombinatorialTests.XUnit - package for MSTest:
SolidCode.CombinatorialTests.MSTest
For example, you can install the SolidCode.CombinatorialTests.XUnit library using the following command:
dotnet add package SolidCode.CombinatorialTests.XUnitor via NuGet Package Manager in Visual Studio:
PM> Install-Package SolidCode.CombinatorialTests.XUnitUsage is the same for xUnit and MSTest.
- Add the
[CombinatorialData]attribute to the test method that has parameters to make it a combinatorial test method. - Specify a set of values for each parameter, or use the default set where supported and appropriate:
- There is no need to specify anything to use the default set of values for supported types (see the list of supported types below).
- Use the values attribute to specify a set of values if the type has no default set of values, or to provide your own set (see the list of available attributes below).
-
[CombinatorialValues(params object?[] values)]- Specifies a set of values for a parameter in a combinatorial test. -
[CombinatorialRangeValues<TNumber>(TNumber start, TNumber max, TNumber step)]- Specifies a set of range-based values for a parameter in a combinatorial test.
NOTE: The .NET Standard 2.0 build implements a non-generic, limited version of this attribute.
-
[CombinatorialMemberValues(Type sourceType, string memberName)]- Specifies a set of values for a parameter in a combinatorial test generated by the member of the specified type. If thesourceTypeis not specified, the type of the current test class is used.
[CombinatorialData]
public async Task SomeTestAsync(
[CombinatorialValues(7, 42, 255)]
uint id,
bool isActive,
[CombinatorialMemberValues(memberName: nameof(_raitingValues))]
Raiting rating,
[CombinatorialRange<uint>(start: 1, end: 10, step: 2)]
uint referenceId,
[CombinatorialRangeValues("comment 1", "comment 2", "comment 3")]
string comment)
{
// Test method body
}| Type | Default set |
|---|---|
| bool |
false, true
|
| bool? |
false, true, null
|
| byte |
0, 1
|
| byte? |
0, 1, null
|
| short |
-1, 0, 1
|
| short? |
-1, 0, 1, null
|
| int |
-1, 0, 1
|
| int? |
-1, 0, 1, null
|
| uint |
0U, 1U
|
| uint? |
0U, 1U, null
|
| long |
-1L, 0L, 1L
|
| long? |
-1L, 0L, 1L, null
|
| ulong |
0UL, 1UL
|
| ulong? |
0UL, 1UL, null
|
| float |
-1f, 0f, 1f
|
| float? |
-1f, 0f, 1f, null
|
| double |
-1d, 0d, 1d
|
| double? |
-1d, 0d, 1d, null
|
| decimal |
-1m, 0m, 1m
|
| decimal? |
-1m, 0m, 1m, null
|
| char |
'a', 'z'
|
| char? |
'a', 'z', null
|
This library is licensed under the MIT License.