TekOnline

.NET Testing Cheat Sheet 🧪

Quick Start Commands

1. Navigate to Test Directory

cd "CDISV2Core.E2ETests"

2. Start the Main Application (Required for E2E Tests)

# From project root
cd CDISV2Core
dotnet run --urls="https://localhost:7064;http://localhost:7065"

# Or with specific profile
dotnet run --launch-profile "https"

3. Run All Tests

# In E2E test directory
dotnet test

# With detailed output
dotnet test --logger "console;verbosity=detailed"

Specific Test Commands

Run Single Test Method

dotnet test --filter "TestMethodName"

# Examples:
dotnet test --filter "DiagnoseModalContent_DetailedAnalysis"
dotnet test --filter "CreateDoctorModal_ShouldOpenAndClose"
dotnet test --filter "CreateDoctor_MissingRequiredFields_ShouldShowValidationErrors"

Run Tests by Class

dotnet test --filter "ClassName"

# Example:
dotnet test --filter "DoctorCrudTests"

Run Tests by Category/Collection

dotnet test --filter "Category=E2E"
dotnet test --filter "Collection=\"Doctor E2E Tests\""

Run Multiple Tests with Pattern

# Run all tests containing "Doctor"
dotnet test --filter "FullyQualifiedName~Doctor"

# Run all Create tests
dotnet test --filter "FullyQualifiedName~Create"

Build & Test Commands

Clean Build Before Testing

dotnet clean
dotnet build
dotnet test

Build Only (No Test Run)

dotnet build --no-restore

Restore Dependencies

dotnet restore

Test Output & Debugging

Run with Maximum Verbosity

dotnet test --logger "console;verbosity=diagnostic"

Generate Test Report

dotnet test --logger "trx;LogFileName=test_results.trx"

Run Tests with Screenshots (E2E)

# Screenshots are automatically saved in Screenshots/ folder
dotnet test --filter "DoctorCrudTests"

Capture Console Output

dotnet test --logger "console;verbosity=normal" > test_output.txt 2>&1

Performance & Timing

Parallel Test Execution

# Run tests in parallel (faster)
dotnet test --parallel

# Disable parallel execution (safer for E2E)
dotnet test --parallel-disabled

Test Timeouts

  • Default test timeout: 30 seconds (configured in appsettings.json)
  • Modal wait times: 2-3 seconds for animations
  • Page load wait: 3 seconds for DataTables

Test Development Cycle

  1. Kill any running processes: taskkill //F //IM CDISV2Core.exe
  2. Start server: cd CDISV2Core && dotnet run
  3. Run specific test: dotnet test --filter "TestName"
  4. Check screenshots in Screenshots/ folder
  5. Repeat until passing

This cheat sheet covers all the essential commands for running and managing your .NET E2E tests! 🚀


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *