|
| 1 | +# NetEvolve.CodeBuilder.Tests.Integration |
| 2 | + |
| 3 | +This project contains integration tests for the NetEvolve.CodeBuilder library, focusing on end-to-end testing scenarios that validate the complete functionality of the code generation capabilities. |
| 4 | + |
| 5 | +## Test Framework |
| 6 | + |
| 7 | +- **TUnit**: Primary testing framework |
| 8 | +- **Verify.TUnit**: For snapshot testing (to be enabled when environment supports it) |
| 9 | +- **No Mocking**: Tests use real instances and validate actual output |
| 10 | + |
| 11 | +## Test Organization |
| 12 | + |
| 13 | +The integration tests are organized into partial classes for better maintainability: |
| 14 | + |
| 15 | +### CSharpCodeBuilderIntegrationTests.ComplexGeneration.cs |
| 16 | +- Complete class generation with documentation |
| 17 | +- Interface generation with multiple methods |
| 18 | +- Real-world code generation scenarios |
| 19 | + |
| 20 | +### CSharpCodeBuilderIntegrationTests.ConditionalGeneration.cs |
| 21 | +- Conditional content generation using AppendIf methods |
| 22 | +- Reflection-based code generation patterns |
| 23 | +- Dynamic property and method generation |
| 24 | + |
| 25 | +### CSharpCodeBuilderIntegrationTests.Formatting.cs |
| 26 | +- Indentation testing (spaces vs tabs) |
| 27 | +- Code formatting validation |
| 28 | +- Enum generation with attributes |
| 29 | + |
| 30 | +### CSharpCodeBuilderIntegrationTests.SnapshotTests.cs |
| 31 | +- Placeholder for snapshot tests using Verify.TUnit |
| 32 | +- Will be enabled when framework compatibility is resolved |
| 33 | + |
| 34 | +## Test Scenarios |
| 35 | + |
| 36 | +The integration tests cover: |
| 37 | + |
| 38 | +1. **End-to-End Class Generation**: Complete C# classes with proper indentation, documentation, and structure |
| 39 | +2. **Interface Generation**: Service interfaces with async methods and documentation |
| 40 | +3. **Conditional Logic**: Using AppendIf and AppendLineIf for dynamic content |
| 41 | +4. **Formatting Options**: Testing both space and tab-based indentation |
| 42 | +5. **Complex Structures**: Enums with attributes, nested code blocks, exception handling |
| 43 | + |
| 44 | +## Running Tests |
| 45 | + |
| 46 | +```bash |
| 47 | +# Run all integration tests |
| 48 | +dotnet test tests/NetEvolve.CodeBuilder.Tests.Integration/ |
| 49 | + |
| 50 | +# Run specific test class |
| 51 | +dotnet test tests/NetEvolve.CodeBuilder.Tests.Integration/ --filter "ClassName=CSharpCodeBuilderIntegrationTests" |
| 52 | +``` |
| 53 | + |
| 54 | +## Adding New Tests |
| 55 | + |
| 56 | +When adding new integration tests: |
| 57 | + |
| 58 | +1. Follow the existing naming convention: `MethodName_Condition_Should_ExpectedResult` |
| 59 | +2. Use the [Test] attribute from TUnit |
| 60 | +3. Use partial classes to organize related tests |
| 61 | +4. Validate both content and formatting in assertions |
| 62 | +5. Include real-world scenarios that developers would encounter |
| 63 | + |
| 64 | +## Future Enhancements |
| 65 | + |
| 66 | +- Snapshot testing with Verify.TUnit when framework support is available |
| 67 | +- Performance benchmarking for large code generation scenarios |
| 68 | +- Cross-platform indentation testing |
| 69 | +- Template-based code generation tests |
0 commit comments