Optivem.Testing 1.0.6

dotnet add package Optivem.Testing --version 1.0.6
                    
NuGet\Install-Package Optivem.Testing -Version 1.0.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Optivem.Testing" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Optivem.Testing" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Optivem.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Optivem.Testing --version 1.0.6
                    
#r "nuget: Optivem.Testing, 1.0.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Optivem.Testing@1.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Optivem.Testing&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Optivem.Testing&version=1.0.6
                    
Install as a Cake Tool

Optivem Testing (.NET)

Commit Stage Acceptance Stage Release Stage

NuGet License

Optivem.Testing is an xUnit extension for channel-based data-driven testing. It enables you to run the same tests across multiple channels (UI, API, etc.) with automatic Cartesian product generation, test isolation markers, and time-dependent test support.

Features

Channel-Based Testing - Run tests across multiple channels (UI, API, etc.)
Cartesian Product Generation - Automatically combine channels with test data
Flexible Data Sources - Supports inline data, class data, and member data
Test Isolation - Mark tests that require isolation ([Isolated])
Time-Dependent Tests - Mark time-sensitive tests ([Time])
.NET 8+ - Modern .NET support

Installation

dotnet add package Optivem.Testing

Quick Start

Basic Channel Testing

Run the same test across multiple channels:

[Theory]
[ChannelData("UI", "API")]
public void CreateOrder_ShouldSucceed(Channel channel)
{
    // Arrange
    var order = new Order { ProductId = "P1", Quantity = 1 };
    
    // Act
    var result = channel.Type == "UI" 
        ? CreateOrderViaUI(order) 
        : CreateOrderViaAPI(order);
    
    // Assert
    result.Success.ShouldBeTrue();
}
// Generates 2 tests: CreateOrder_ShouldSucceed(UI), CreateOrder_ShouldSucceed(API)

Channel + Inline Data (Cartesian Product)

Combine channels with test data for comprehensive coverage:

[Theory]
[ChannelData("UI", "API")]
[ChannelInlineData("", "Country must not be empty")]
[ChannelInlineData("   ", "Country must not be empty")]
[ChannelInlineData("123", "Country must contain only letters")]
public void CreateOrder_InvalidCountry_ShouldFail(
    Channel channel, 
    string country, 
    string expectedError)
{
    // Test implementation validates error message
}
// Generates 6 tests: 2 channels × 3 data rows

Channel + Class Data

Use a class to provide test data:

public class InvalidCountryData : IEnumerable<object[]>
{
    public IEnumerator<object[]> GetEnumerator()
    {
        yield return new object[] { "", "Country must not be empty" };
        yield return new object[] { "   ", "Country must not be empty" };
        yield return new object[] { "123", "Country must contain only letters" };
    }
    
    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

[Theory]
[ChannelData("UI", "API")]
[ChannelClassData(typeof(InvalidCountryData))]
public void CreateOrder_InvalidCountry_ShouldFail(
    Channel channel, 
    string country, 
    string expectedError)
{
    // Test implementation
}

Channel + Member Data

Use a method or property to provide test data:

public static IEnumerable<object[]> GetInvalidCountries()
{
    yield return new object[] { "", "Country must not be empty" };
    yield return new object[] { "   ", "Country must not be empty" };
    yield return new object[] { "123", "Country must contain only letters" };
}

[Theory]
[ChannelData("UI", "API")]
[ChannelMemberData(nameof(GetInvalidCountries))]
public void CreateOrder_InvalidCountry_ShouldFail(
    Channel channel, 
    string country, 
    string expectedError)
{
    // Test implementation
}

Test Isolation

Mark tests that require isolation from other tests:

[Fact]
[Isolated("Deletes all orders from database")]
public void ClearAllOrders_ShouldDeleteAllRecords()
{
    // This test modifies shared state
}

Filter isolated tests:

# Run ONLY isolated tests
dotnet test --filter "Category=isolated"

# Run all EXCEPT isolated tests
dotnet test --filter "Category!=isolated"

Time-Dependent Tests

Mark tests that depend on specific times:

[Fact]
[Time("2024-01-15T17:30:00Z")]
public void DiscountRate_ShouldBe15Percent_WhenAfter5pm()
{
    // Test implementation
}

Filter time-dependent tests:

# Run ONLY time-dependent tests
dotnet test --filter "Category=time"

# Run all EXCEPT time-dependent tests
dotnet test --filter "Category!=time"

Best Practices

  1. Channel Naming - Use consistent channel names across your test suite (e.g., "UI", "API", "CLI")
  2. Isolation - Always mark tests with side effects using [Isolated]
  3. Test Data - Use ChannelClassData or ChannelMemberData for complex test data
  4. Time Tests - [Time] tests are automatically marked as [Isolated]

Why Optivem.Testing?

  • Reduce Duplication - Write test logic once, run across all channels
  • Better Coverage - Cartesian products ensure comprehensive testing
  • Clear Intent - Attributes make test requirements explicit
  • Type Safety - Channel type prevents string typos
  • xUnit Compatible - Works seamlessly with existing xUnit tests

Requirements

  • .NET 8.0 or higher
  • xUnit 2.x

License

MIT License

Contributing

Contributions welcome! Please open an issue or submit a pull request.


Built by Optivem

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.6 87 2/10/2026
1.0.5 622 2/9/2026
1.0.4 255 2/6/2026
1.0.3 87 2/6/2026
1.0.2 90 2/6/2026
1.0.1 87 2/6/2026
1.0.0 86 2/6/2026