Includes: - MarketAlly.AIPlugin.Analysis - MarketAlly.AIPlugin.ClaudeCode - MarketAlly.AIPlugin.Context - MarketAlly.AIPlugin.DevOps - MarketAlly.AIPlugin.Learning - MarketAlly.AIPlugin.Refactoring - MarketAlly.AIPlugin.Security - MarketAlly.AIPlugin.All - MarketAlly.ProjectDetector - Test projects 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| Plugins | ||
| Security | ||
| Validation | ||
| AIPluginResultTests.cs | ||
| AgenticEngineBuilderTests.cs | ||
| AgenticEngineBuilderTests.cs.20251207_204310.bak | ||
| AgenticEngineTests.cs | ||
| BasicTests.cs | ||
| MarketAlly.AIPlugin.Tests.csproj | ||
| ProjectFileLocatorTests.cs | ||
| ProjectTypeDetectorTests.cs | ||
| QuickTests.cs | ||
| README.md | ||
README.md
MarketAlly.AIPlugin.Tests
Overview
Comprehensive unit test suite for the MarketAlly.AIPlugin solution, ensuring quality and reliability across core components.
Test Coverage
Core Components
- AIPluginResult: Result object validation and error handling
- AgenticEngine: Core orchestration engine functionality
- AgenticEngineBuilder: Builder pattern and configuration
- ProjectTypeDetector: Project type detection logic
- ProjectFileLocator: File system operations and project discovery
Test Structure
Test Categories
- Constructor Tests: Verify proper initialization
- Validation Tests: Input validation and error handling
- Behavior Tests: Core functionality verification
- Edge Case Tests: Boundary conditions and unusual inputs
- Integration Points: Component interaction validation
Naming Conventions
- Test class:
{ClassName}Tests - Test method:
{MethodName}_{Scenario}_{ExpectedBehavior} - Example:
Constructor_WithNullInput_ShouldThrowArgumentNullException
Running Tests
Visual Studio
Test > Run All Tests
Command Line
dotnet test
With Coverage
dotnet test --collect:"XPlat Code Coverage"
Test Frameworks
Primary
- xUnit: Test framework
- FluentAssertions: Readable assertions
- Moq: Mocking framework
Packages
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Moq" Version="4.20.72" />
Test Patterns
Arrange-Act-Assert (AAA)
[Fact]
public void Method_Scenario_ExpectedBehavior()
{
// Arrange
var input = "test";
// Act
var result = Method(input);
// Assert
result.Should().Be("expected");
}
Theory Tests (Data-Driven)
[Theory]
[InlineData("input1", "expected1")]
[InlineData("input2", "expected2")]
public void Method_WithVariousInputs_ProducesCorrectOutput(string input, string expected)
{
// Arrange & Act
var result = Method(input);
// Assert
result.Should().Be(expected);
}
Exception Testing
[Fact]
public void Method_WithInvalidInput_ShouldThrow()
{
// Arrange
var invalidInput = null;
// Act
Action act = () => Method(invalidInput);
// Assert
act.Should().Throw<ArgumentNullException>()
.WithParameterName("input");
}
Test Guidelines
DO
- ✅ Test one concept per test method
- ✅ Use descriptive test names
- ✅ Follow AAA pattern consistently
- ✅ Test both success and failure paths
- ✅ Test edge cases and boundaries
- ✅ Use FluentAssertions for readability
- ✅ Mock external dependencies
- ✅ Keep tests fast and isolated
DON'T
- ❌ Test implementation details
- ❌ Create interdependent tests
- ❌ Use hardcoded paths or dates
- ❌ Test framework code
- ❌ Ignore failing tests
- ❌ Over-mock (test real behavior when possible)
Coverage Goals
Target Coverage
- Line Coverage: > 80%
- Branch Coverage: > 75%
- Critical Paths: 100%
Priority Areas
- Core business logic
- Error handling paths
- Public API surfaces
- Data validation
- State management
Continuous Integration
Tests are automatically run on:
- Pull requests
- Main branch commits
- Release builds
Build Pipeline
- Restore dependencies
- Build solution
- Run all tests
- Generate coverage report
- Publish results
Troubleshooting
Common Issues
Test Discovery Fails
# Clean and rebuild
dotnet clean
dotnet build
Tests Timeout
// Increase timeout for slow operations
[Fact(Timeout = 5000)] // 5 seconds
Flaky Tests
- Check for timing dependencies
- Verify test isolation
- Review shared state
- Use deterministic data
Contributing
Adding New Tests
- Follow naming conventions
- Use appropriate test framework
- Document complex scenarios
- Update README if needed
- Ensure tests pass locally
Code Review Checklist
- Tests follow AAA pattern
- Descriptive test names
- Edge cases covered
- No hardcoded values
- Proper assertions used
- Tests are isolated
- Documentation updated
Resources
Documentation
Best Practices
Maintenance
Regular Tasks
- Review and update test coverage
- Refactor duplicate test code
- Remove obsolete tests
- Update to latest package versions
- Document new testing patterns
Performance
- Keep test execution time under 5 minutes
- Profile slow tests
- Use parallel execution where safe
- Mock expensive operations
Last Updated: 2024-12-07 Maintained By: QA Team Status: Active Development