AnthonyCMartin.BicepTesting 0.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package AnthonyCMartin.BicepTesting --version 0.1.4
                    
NuGet\Install-Package AnthonyCMartin.BicepTesting -Version 0.1.4
                    
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="AnthonyCMartin.BicepTesting" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AnthonyCMartin.BicepTesting" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="AnthonyCMartin.BicepTesting" />
                    
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 AnthonyCMartin.BicepTesting --version 0.1.4
                    
#r "nuget: AnthonyCMartin.BicepTesting, 0.1.4"
                    
#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 AnthonyCMartin.BicepTesting@0.1.4
                    
#: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=AnthonyCMartin.BicepTesting&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=AnthonyCMartin.BicepTesting&version=0.1.4
                    
Install as a Cake Tool

AnthonyCMartin.BicepTesting

Test the resources, outputs, and diagnostics produced by a Bicep deployment without deploying to Azure. The package can also run opt-in integration tests against a real Azure Deployment Stack when an assertion requires live resources.

This is an independent, non-official project.

Requirements

  • .NET 10 or later
  • A .bicepparam entry point for the deployment under test

Installation

dotnet add package AnthonyCMartin.BicepTesting --version 0.1.4

Snapshot testing

Create and asynchronously dispose a session within the test lifetime:

using AnthonyCMartin.BicepTesting;

await using var session = await BicepTestSession.CreateAsync("0.46.1");
var snapshot = await session.SnapshotAsync(
    "infra/main.bicepparam",
    tenantId: "00000000-0000-0000-0000-000000000000",
    subscriptionId: "00000000-0000-0000-0000-000000000000",
    resourceGroup: "example-rg",
    location: "eastus",
    deploymentName: "example-deployment");

Assert.IsEmpty(snapshot.Diagnostics);
var storageAccounts = snapshot.PredictedResources.Where(
    resource => resource.Type == "Microsoft.Storage/storageAccounts");
Assert.IsTrue(storageAccounts.Any());
Assert.IsTrue(storageAccounts.All(resource =>
    resource.Properties.GetProperty("allowBlobPublicAccess").GetBoolean() is false));

BicepTestSession.CreateAsync() downloads the requested Bicep CLI version and reuses it on later runs. The session owns a Bicep process, so use await using or call DisposeAsync() after the tests finish. Pass the test framework's CancellationToken to session creation and operations when available.

Snapshot tests run locally. The subscription, tenant, resource group, location, and deployment values provide evaluation context only; they do not need to exist, and no Azure credentials are required.

Snapshot results

SnapshotAsync() returns:

  • PredictedResources: resources and resolved properties predicted for the deployment
  • Outputs: resolved deployment outputs
  • Diagnostics: Bicep compilation warnings and errors

Live deployment testing

Use DeployAsync() only when a test must inspect a real Azure resource or service response:

using Azure.Identity;
using System.Text.Json;

await using var deployment = await session.DeployAsync(
    new DefaultAzureCredential(),
    new DeployOptions
    {
        FilePath = "infra/main.bicepparam",
        SubscriptionId = subscriptionId,
        ResourceGroup = resourceGroup,
        StackName = $"bicep-test-{Guid.NewGuid():N}",
        ParameterOverrides = new Dictionary<string, JsonElement>
        {
            ["env"] = JsonSerializer.SerializeToElement("integration"),
        },
    });

Assert.IsTrue(deployment.Resources.Any(
    resource => resource.Type == "Microsoft.Storage/storageAccounts"));

Live tests require Azure credentials, an existing resource group, and permission to create and delete Deployment Stacks and their managed resources. Asynchronous disposal is idempotent and deletes the stack and all resources it manages. Concurrent teardown calls share the same deletion; canceling one caller's wait does not cancel cleanup. Use a unique stack name and keep the result in an await using scope.

More information

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
0.1.6 91 8/10/2026
0.1.5 85 8/10/2026
0.1.4 86 8/10/2026
0.1.3 102 8/10/2026
0.1.2 93 8/9/2026
0.1.1 86 8/9/2026
0.1.0 117 8/9/2026