Overview
Testing is a critical part of contributing to Intent Architect Modules. All contributions must include appropriate test coverage to ensure quality, prevent regressions, and validate functionality across different scenarios.Testing Philosophy
Test Coverage
All new features and bug fixes must include corresponding tests that validate the expected behavior.
Integration Tests
Test modules in realistic scenarios using the Intent Architect test solution to ensure proper integration.
Automated Validation
Tests run automatically in the CI/CD pipeline to catch issues before they reach production.
Test Maintenance
Keep tests up-to-date as code evolves. Failing tests must be fixed or updated, not disabled.
Test Structure
The repository contains two primary testing locations:Tests Directory Structure
Test Project Types
- Unit Tests
- Integration Tests
- Accelerator Tests
Unit tests within individual module projects test specific functionality in isolation.
Writing Tests
Test Cases in Intent Architect Solution
The primary testing approach uses the Intent Architect test solution:Open the test solution
Open the Intent Architect test solution:This solution contains test applications that reference your modules.
Add test scenarios
Create or update test applications to exercise your module’s functionality:
- Add models that trigger your templates
- Configure module settings to test different scenarios
- Add stereotypes and metadata to validate behaviors
Run Software Factory
Execute the Software Factory to generate code:This validates that:
- Your module generates expected code
- No outstanding changes exist (generated code matches expectations)
- Module integrates properly with dependencies
C# Unit Tests
For module-specific logic, write C# unit tests:Test Naming Conventions
Follow consistent naming patterns:Running Tests
Running All Tests Locally
Run pre-commit checks
Execute the comprehensive pre-commit validation:This runs:
- Pre-build validations
- Software Factory change detection
- Module builds
- Test solution validation
- All unit and integration tests
Pipeline Test Execution
The Azure DevOps pipeline (azure-pipelines.yml) automatically runs tests:
Tests tagged with
Requirement=CosmosDB are excluded from CI runs as they require external infrastructure.Test Result Publishing
Test results are automatically published:- Console output during CI/CD execution
- Test result files (
.trx) for detailed analysis - Pipeline artifacts on failure for debugging
Test Coverage Requirements
What to Test
Template Generation
Template Generation
Verify templates generate correct code:
- Output matches expected format
- Code compiles successfully
- Proper handling of edge cases
- Template dependencies resolve correctly
Module Integration
Module Integration
Test module interactions:
- Dependencies load correctly
- Modules don’t conflict
- Shared resources accessed properly
- Stereotypes and metadata propagate
Business Logic
Business Logic
Validate core functionality:
- Algorithms produce correct results
- Validation rules work as expected
- Error conditions handled properly
- Edge cases covered
Configuration
Configuration
Test module settings:
- Default values applied
- Custom configurations respected
- Invalid settings rejected
- Settings persist correctly
Coverage Guidelines
- New Features: 80%+ code coverage required
- Bug Fixes: Add test that reproduces the bug, then fix
- Critical Paths: 100% coverage for critical functionality
- Public APIs: All public methods should have tests
Testing Best Practices
AAA Pattern
Structure tests using Arrange-Act-Assert:Test Isolation
Descriptive Assertions
Test Data Builders
Debugging Test Failures
Local Debugging
Run tests in debug mode
In Visual Studio or Rider:
- Set breakpoints in test or production code
- Right-click test → Debug
- Step through execution
CI/CD Debugging
When tests fail in the pipeline:- Review pipeline logs: Check the Azure DevOps pipeline output
- Download artifacts: Failed test runs publish artifacts with detailed logs
- Reproduce locally: Run the same test command locally
- Check for environment differences: Verify .NET versions, dependencies, etc.
Continuous Integration
All tests run automatically on:- Pull Requests: Tests must pass before merging
- Master Branch: Validates production-ready code
- Development Branches: Early feedback on changes
Build Status
Monitor build status:- Build badge in README shows current status
- Azure DevOps pipeline provides detailed results
- Failed builds prevent module publishing
Next Steps
With testing knowledge:- Write tests for your changes
- Ensure all tests pass locally
- Review the Pull Request Process to submit your contribution