Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 22, 2025

This PR creates a comprehensive integration test project for the NetEvolve.CodeBuilder library following the established folder structure and testing conventions.

Project Structure

The new NetEvolve.CodeBuilder.Tests.Integration project is created under tests/ following the folder structure decision (2025-07-10-folder-structure-and-naming-conventions.md):

tests/
├── NetEvolve.CodeBuilder.Tests.Unit/         # Existing unit tests
└── NetEvolve.CodeBuilder.Tests.Integration/  # New integration tests
    ├── CSharpCodeBuilderIntegrationTests.cs
    ├── CSharpCodeBuilderIntegrationTests.ComplexGeneration.cs
    ├── CSharpCodeBuilderIntegrationTests.ConditionalGeneration.cs
    ├── CSharpCodeBuilderIntegrationTests.Formatting.cs
    ├── CSharpCodeBuilderIntegrationTests.SnapshotTests.cs
    ├── README.md
    └── NetEvolve.CodeBuilder.Tests.Integration.csproj

Test Framework & Dependencies

The project uses:

  • TUnit as the primary testing framework
  • Verify.TUnit for snapshot testing capabilities
  • NetEvolve.Extensions.TUnit with IntegrationTestAttribute
  • Microsoft.Testing.Extensions.CodeCoverage for coverage reporting

Integration Test Coverage

The integration tests validate end-to-end scenarios including:

Complex Code Generation

  • Complete C# class generation with XML documentation
  • Interface generation with async methods
  • Proper namespace and using statement handling

Conditional Content Generation

  • Dynamic method generation using AppendIf patterns
  • Reflection-based property generation
  • Template-driven code creation

Formatting & Indentation

  • Space-based indentation (4 spaces per level)
  • Tab-based indentation validation
  • Nested code block formatting
  • Enum generation with attributes

Example Test

[Test]
public async Task GenerateCompleteClass_Should_ProduceCorrectOutput()
{
    var builder = new CSharpCodeBuilder();
    
    builder
        .AppendLine("using System;")
        .AppendLine("namespace MyApplication.Models")
        .Append("{")
        .AppendLine("public class Customer")
        .Append("{")
        .AppendLine("public string Id { get; set; }")
        .Append("}")
        .Append("}");
    
    var result = builder.ToString();
    
    _ = await Assert.That(result).Contains("namespace MyApplication.Models");
    _ = await Assert.That(result).Contains("    public class Customer");
    _ = await Assert.That(result).Contains("        public string Id { get; set; }");
}

Key Features

  • No Mocking: All tests use real CSharpCodeBuilder instances
  • End-to-End Validation: Tests verify both content and formatting
  • Real-World Scenarios: Covers actual code generation use cases
  • Snapshot Testing Ready: Infrastructure prepared for Verify.TUnit snapshot tests
  • Comprehensive Documentation: Includes README with usage examples

All 7 integration tests pass successfully, validating the complete functionality of the CodeBuilder library's code generation capabilities.

Fixes #12.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Creation of Integration Tests Create integration test project for NetEvolve.CodeBuilder library Aug 22, 2025
@Copilot Copilot AI requested a review from samtrion August 22, 2025 17:33
Copilot finished work on behalf of samtrion August 22, 2025 17:33
@Copilot Copilot AI requested a review from samtrion August 22, 2025 17:45
Copilot finished work on behalf of samtrion August 22, 2025 17:45
Copilot AI and others added 3 commits August 23, 2025 10:33
… end-to-end tests

Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
…hot test placeholders

Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
@samtrion samtrion marked this pull request as ready for review August 23, 2025 10:39
@samtrion samtrion requested a review from Copilot August 23, 2025 10:39
Copilot

This comment was marked as outdated.

@samtrion samtrion requested a review from Copilot August 25, 2025 07:43
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR creates a comprehensive integration test project for the NetEvolve.CodeBuilder library, providing end-to-end validation of the code generation capabilities. The integration tests validate real-world scenarios including complete C# class generation, interface creation, conditional content generation, and formatting with different indentation styles.

  • Establishes new integration test project with TUnit and Verify.TUnit frameworks
  • Implements comprehensive test coverage for complex code generation scenarios
  • Adds snapshot testing infrastructure for regression testing

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/NetEvolve.CodeBuilder.Tests.Integration/NetEvolve.CodeBuilder.Tests.Integration.csproj New test project configuration with TUnit and Verify.TUnit dependencies
tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.cs Main test class definition with TestGroup attribute
tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ComplexGeneration.cs Tests for complete class and interface generation with XML documentation
tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ConditionalGeneration.cs Tests for conditional content generation and reflection-based code creation
tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.Formatting.cs Tests for indentation formatting with spaces and tabs
tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.SnapshotTests.cs Snapshot testing implementation for regression testing
tests/NetEvolve.CodeBuilder.Tests.Integration/Startup.cs Module initializer for Verify.TUnit configuration
tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/* Generated snapshot files for test verification
CodeBuilder.slnx Solution file updated to include the new test project
Directory.Packages.props Added Verify.ParametersHashing and Verify.TUnit package references
Directory.Build.props Updated test target frameworks to exclude net6.0 and net7.0
src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Documentation.cs Removed unused System using statement

@samtrion samtrion closed this Aug 25, 2025
@samtrion samtrion reopened this Aug 25, 2025
Copy link

codecov bot commented Aug 25, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@samtrion samtrion merged commit 45354b4 into main Aug 25, 2025
14 checks passed
@samtrion samtrion deleted the copilot/fix-12 branch August 25, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creation of Integration Tests
2 participants