Skip to content

Latest commit

Β 

History

History
88 lines (69 loc) Β· 3.05 KB

File metadata and controls

88 lines (69 loc) Β· 3.05 KB

πŸ§ͺ Unit Test Action - Integration Test Exclusion

βœ… Updated Behavior:

The unittest/action.yaml now automatically excludes test projects ending with Integration.csproj from unit test runs.

πŸ” What Gets Excluded:

βœ… Will run unit tests:
- ProjectName.Tests.csproj
- ProjectName.UnitTests.csproj  
- ProjectName.Tests.Unit.csproj
- ProjectName.ComponentTests.csproj

🚫 Will exclude from unit tests:
- ProjectName.Integration.csproj
- ProjectName.Tests.Integration.csproj
- ProjectName.IntegrationTests.Integration.csproj

πŸ“‹ Example Output:

πŸ” Searching for test projects matching pattern: **/*Tests/*.csproj
🚫 Excluding integration test projects (ending with Integration.csproj)
🚫 Excluding integration test: ./tests/Conferenti.Api.Tests.Integration.csproj
🚫 Excluding integration test: ./tests/Conferenti.Services.Integration.csproj
βœ… Running unit tests on projects:
  πŸ“¦ ./tests/Conferenti.Api.Tests.csproj
  πŸ“¦ ./tests/Conferenti.Services.Tests.csproj
  πŸ“¦ ./tests/Conferenti.Domain.UnitTests.csproj
πŸ§ͺ Running tests for: ./tests/Conferenti.Api.Tests.csproj
πŸ§ͺ Running tests for: ./tests/Conferenti.Services.Tests.csproj
πŸ§ͺ Running tests for: ./tests/Conferenti.Domain.UnitTests.csproj

🎯 Usage Example:

- name: Run Unit Tests Only
  uses: ./unittest
  with:
    solution-path: './Conferenti.sln'
    test-projects: '**/*Tests/*.csproj'  # Finds all test projects
    collect-coverage: 'true'
    # Integration.csproj files are automatically excluded

πŸ”§ How It Works:

  1. πŸ” Discovery: Finds all projects matching the test-projects pattern
  2. 🚫 Filtering: Removes any project files ending with Integration.csproj
  3. πŸ“‹ Logging: Shows which projects are excluded and which will run
  4. πŸ§ͺ Execution: Runs tests only on the remaining unit test projects

πŸ—οΈ Project Structure Support:

tests/
β”œβ”€β”€ Conferenti.Api.Tests.csproj              βœ… Runs (unit tests)
β”œβ”€β”€ Conferenti.Api.Tests.Integration.csproj  🚫 Excluded (integration)
β”œβ”€β”€ Conferenti.Services.Tests.csproj         βœ… Runs (unit tests) 
β”œβ”€β”€ Conferenti.Services.Integration.csproj   🚫 Excluded (integration)
└── Conferenti.Domain.UnitTests.csproj       βœ… Runs (unit tests)

πŸ’‘ Benefits:

  • ⚑ Faster Builds: Unit tests run separately from integration tests
  • 🎯 Separation: Clear distinction between unit and integration test execution
  • πŸ” Visibility: Clear logging of which projects are included/excluded
  • πŸ› οΈ Flexible: Still uses the same test-projects pattern input

πŸ”— Integration Tests:

Use the separate integrationtest/action.yaml for running integration tests:

- name: Run Integration Tests
  uses: ./integrationtest
  with:
    system_name: "conferenti"
    test-projects: '**/*Integration*.csproj'
    environment: "test"

Unit tests and integration tests are now properly separated! πŸš€