con un clic
fix-test-failures
// This skill should be used after running tests when failures occur. It provides a systematic approach to diagnosing test failures through instrumentation and root cause analysis.
// This skill should be used after running tests when failures occur. It provides a systematic approach to diagnosing test failures through instrumentation and root cause analysis.
This skill provides guidance for fixing file size violations detected by FileComplianceTests. Use when a C# file exceeds its line limit (800 lines default, or explicit limit for legacy files). The skill explains strategies to reduce file size while maintaining code quality.
This skill provides guidance on writing and running tests in this project. It should be used when writing new tests, understanding the test infrastructure, or making decisions about what to test. Covers TUnit configuration, unit tests, automation tests, and testing best practices.
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
Automates the full commit workflow: analyzes changes, writes commit message, stages files, commits, and handles test failures by fixing them until the commit succeeds. Use when the user wants to commit their changes.
| name | fix-test-failures |
| description | This skill should be used after running tests when failures occur. It provides a systematic approach to diagnosing test failures through instrumentation and root cause analysis. |
This skill provides a systematic approach to diagnosing and fixing test failures.
When a test fails, the goal is to understand what went wrong before changing anything. A test failure is valuable information -- it's telling you something about the system that you didn't expect. The worst thing you can do is silence that signal without understanding it.
Most of the time, a failing test reveals a real bug in the production code. Occasionally, the test itself has a problem -- an incorrect assumption, a setup issue, or a requirement that genuinely changed. Either way, the path forward is the same: investigate until you understand, then make the right fix.
Run the failing test(s) to see the current error:
# Run all tests
dotnet test Tests/Agg.Tests/Agg.Tests.csproj
# Run with detailed output
dotnet test Tests/Agg.Tests/Agg.Tests.csproj --verbosity normal
# Run a specific test class
dotnet test Tests/Agg.Tests/Agg.Tests.csproj --filter "FullyQualifiedName~ClassName"
# Run a specific test method
dotnet test Tests/Agg.Tests/Agg.Tests.csproj --filter "FullyQualifiedName~MethodName"
Record the exact error message and stack trace. This is your starting point.
Before adding instrumentation, read the test carefully:
Add Console.WriteLine statements to expose state at key points. The goal is to see what's actually happening inside the code, not just what the test reports.
For state-related failures:
Console.WriteLine($"State before operation: {state}");
// ... operation ...
Console.WriteLine($"State after operation: {state}");
For object inspection:
Console.WriteLine($"Children count: {obj.Children.Count}");
Console.WriteLine($"Mesh vertices: {obj.Mesh?.Vertices.Count ?? 0}");
For execution flow:
Console.WriteLine($"Entering {nameof(MethodName)} with: {param}");
// ... method body ...
Console.WriteLine($"Returning: {result}");
Run the test again with verbose output:
dotnet test Tests/Agg.Tests/Agg.Tests.csproj --filter "FullyQualifiedName~TestMethod" --verbosity normal
Look at the output to understand:
Based on instrumentation output, determine what's actually wrong:
What you fix depends on what you found:
Common production code fixes:
Path.Combine and platform-appropriate pathsdotnet test Tests/Agg.Tests/Agg.Tests.csprojThese approaches might feel like they solve the problem, but they hide it instead:
[Skip] permanently means the test exists but protects nothing. If it's not worth fixing, it's not worth keeping.These aren't forbidden -- they're just counterproductive. If you find yourself reaching for one, it usually means you haven't found the root cause yet.
If the first round of instrumentation doesn't reveal the issue:
[Before(Class)])Keep iterating until the root cause is clear. The goal is understanding, then fixing.
Tests/
Agg.Tests/
Agg.Tests.csproj # TUnit test project (net8.0-windows)
Agg/ # Core graphics tests
Agg.UI/ # GUI widget tests
Agg Automation Tests/ # GUI automation tests
Agg.PolygonMesh/ # Mesh tests
Agg.RayTracer/ # Ray tracer tests
Agg.VectorMath/ # Vector math tests
Agg.Csg/ # CSG tests
Other/ # Misc tests (affine, clipper, etc.)
TestingInfrastructure/ # Test setup helpers
Key patterns:
[Test] methods[NotInParallel] with AutomationRunner.ShowWindowAndExecuteTests[Before(Class)] for one-time initializationawait Assert.That(value).IsEqualTo(expected)