steering_docs/dotnet-tech/tests.md
šØ CRITICAL - Must be completed BEFORE any code generation
# Step 1: List available knowledge bases
ListKnowledgeBases()
# Step 2: Query coding standards (REQUIRED)
QueryKnowledgeBases("coding-standards-KB", "dotnet-code-example-standards")
# Step 3: Query implementation patterns (REQUIRED)
QueryKnowledgeBases("DotNet-premium-KB", ".NET implementation patterns testing")
# Step 4: AWS service research (REQUIRED)
search_documentation("What is [AWS Service] and what are its key API operations?")
read_documentation("https://docs.aws.amazon.com/[service]/latest/[relevant-page]")
FAILURE TO COMPLETE KNOWLEDGE BASE CONSULTATION WILL RESULT IN INCORRECT CODE STRUCTURE
Generate integration test suites using xUnit framework to validate complete scenario workflows against real AWS services.
dotnetv4/{Service}/Tests/
āāā {Service}Tests.csproj # Test project file
āāā {Service}IntegrationTests.cs # Integration tests
CRITICAL:
<!-- dotnetv4/{Service}/Tests/{Service}Tests.csproj -->
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AssemblyName>{Service}Tests</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AWSSDK.{Service}" Version="3.7.401" />
<PackageReference Include="AWSSDK.{ServiceDataAPI}" Version="3.7.401" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Actions\{Service}Actions.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="settings.*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DependentUpon>settings.json</DependentUpon>
</Content>
</ItemGroup>
</Project>
Key Changes:
// dotnetv4/{Service}/Tests/{Service}IntegrationTests.cs
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
using System.Threading.Tasks;
using Amazon.{Service};
using Amazon.{ServiceDataAPI};
using {Service}Actions;
using Xunit;
namespace {Service}Tests;
/// <summary>
/// Integration tests for Amazon {Service} operations.
/// These tests require actual AWS credentials and will create real AWS resources.
/// </summary>
public class {Service}IntegrationTests
{
/// <summary>
/// Verifies the scenario with an integration test. No exceptions should be thrown.
/// </summary>
/// <returns>Async task.</returns>
[Fact]
[Trait("Category", "Integration")]
public async Task TestScenarioIntegration()
{
// Arrange
{Service}Basics.{Service}Basics.IsInteractive = false;
// Act
{Service}Basics.{Service}Basics.Wrapper = new {Service}Wrapper(
new Amazon{Service}Client(),
new Amazon{ServiceDataAPI}Client());
await {Service}Basics.{Service}Basics.RunScenarioAsync();
// Assert - if we get here without exceptions, the test passes
}
}
Key Changes:
The integration test should run the complete scenario end-to-end:
/// <summary>
/// Verifies the scenario with an integration test. No exceptions should be thrown.
/// </summary>
/// <returns>Async task.</returns>
[Fact]
[Trait("Category", "Integration")]
public async Task TestScenarioIntegration()
{
// Arrange
{Service}Basics.{Service}Basics.IsInteractive = false;
// Act
{Service}Basics.{Service}Basics.Wrapper = new {Service}Wrapper(
new Amazon{Service}Client(),
new Amazon{ServiceDataAPI}Client());
await {Service}Basics.{Service}Basics.RunScenarioAsync();
// Assert - if we get here without exceptions, the test passes
}
Key Points:
[Fact] attribute for test methods[Trait("Category", "Integration")] for categorizationIsInteractive = false to run without user inputRunScenarioAsync() methoddotnet test dotnetv4/{Service}/{Service}Examples.sln
dotnet test dotnetv4/{Service}/Tests/{Service}Tests.csproj --filter TestCategory=Integration
dotnet test dotnetv4/{Service}/Tests/{Service}Tests.csproj --filter "TestCategory=Integration&TestCategory!=LongRunning"
[Fact], [Trait("Category", "Integration")])RunScenarioAsync()async TaskThe main integration test should:
RunScenarioAsync()[Fact], [Trait]) for test organization[Fact], [Trait]) for integration tests