Skip to content

topemalheiro/ETL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Test Automation Framework

A comprehensive C# test automation framework demonstrating modern automation engineering practices including Selenium WebDriver UI testing, REST API testing, cross-browser compatibility, containerization, and CI/CD integration.

πŸš€ Features

Core Capabilities

  • Cross-Browser Testing: Chrome, Firefox, Edge support with automatic driver management
  • API Testing: RESTful API testing with authentication, validation, and error handling
  • Page Object Model: Scalable UI test architecture with reusable page components
  • Parallel Execution: Concurrent test execution for faster feedback
  • CI/CD Integration: GitHub Actions pipeline with comprehensive reporting
  • Docker Support: Containerized test execution for consistent environments
  • Structured Logging: Detailed test execution logs with Serilog
  • Screenshot Capture: Automatic screenshots on test failures
  • Test Reporting: Multiple output formats (TRX, JSON, HTML)

Technology Stack

  • .NET 8: Modern C# development platform
  • NUnit: Testing framework with rich assertion library
  • Selenium WebDriver: Browser automation and UI testing
  • HttpClient: REST API testing and validation
  • Docker: Containerized test execution
  • GitHub Actions: CI/CD pipeline automation
  • Serilog: Structured logging and diagnostics

πŸ“ Project Structure

TestAutomationFramework/
β”œβ”€β”€ TestFramework/                 # Core framework components
β”‚   β”œβ”€β”€ DriverFactory.cs          # WebDriver factory with cross-browser support
β”‚   β”œβ”€β”€ BasePage.cs               # Base page object model class
β”‚   └── ApiClient.cs              # REST API client with authentication
β”œβ”€β”€ UI.AutomationTests/           # User interface test suite
β”‚   β”œβ”€β”€ Pages/                    # Page object model implementations
β”‚   β”‚   β”œβ”€β”€ GoogleHomePage.cs     # Google home page interactions
β”‚   β”‚   └── GoogleSearchResultsPage.cs # Search results page
β”‚   └── Tests/                    # UI test implementations
β”‚       └── GoogleSearchTests.cs  # Search functionality tests
β”œβ”€β”€ API.AutomationTests/          # API test suite
β”‚   └── Tests/
β”‚       └── JsonPlaceholderApiTests.cs # REST API CRUD tests
β”œβ”€β”€ .github/workflows/            # CI/CD pipeline definitions
β”‚   └── test-automation.yml      # GitHub Actions workflow
β”œβ”€β”€ Dockerfile                    # Container configuration
β”œβ”€β”€ appsettings.json             # Framework configuration
└── README.md                    # This documentation

πŸ› οΈ Setup Instructions

Prerequisites

  • .NET 8 SDK
  • Chrome/Firefox/Edge browsers
  • Docker (optional for containerized execution)
  • Git

Manual Setup (Step-by-Step)

  1. Create Solution Structure

    # Create main directory
    mkdir TestAutomationFramework
    cd TestAutomationFramework
    
    # Create solution
    dotnet new sln -n "TestAutomationFramework"
    
    # Create projects
    dotnet new classlib -n "TestFramework" -f net8.0
    dotnet new nunit -n "UI.AutomationTests" -f net8.0
    dotnet new nunit -n "API.AutomationTests" -f net8.0
    
    # Add projects to solution
    dotnet sln add TestFramework/TestFramework.csproj
    dotnet sln add UI.AutomationTests/UI.AutomationTests.csproj
    dotnet sln add API.AutomationTests/API.AutomationTests.csproj
  2. Install NuGet Packages

    # Framework packages
    cd TestFramework
    dotnet add package Selenium.WebDriver
    dotnet add package Selenium.WebDriver.ChromeDriver
    dotnet add package Selenium.Support
    dotnet add package DotNetSeleniumExtras.WaitHelpers
    dotnet add package Microsoft.Extensions.Configuration.Json
    dotnet add package Serilog
    dotnet add package Newtonsoft.Json
    
    # Add project references
    cd ../UI.AutomationTests
    dotnet add reference ../TestFramework/TestFramework.csproj
    
    cd ../API.AutomationTests
    dotnet add reference ../TestFramework/TestFramework.csproj
  3. Build Solution

    cd ..
    dotnet build --configuration Release

🎯 Running Tests

Local Execution

Run All Tests

dotnet test --configuration Release

Run Specific Test Suites

# API tests only
dotnet test API.AutomationTests/API.AutomationTests.csproj

# UI tests only
dotnet test UI.AutomationTests/UI.AutomationTests.csproj

Cross-Browser Testing

# Chrome (default)
$env:BROWSER="Chrome"
dotnet test UI.AutomationTests/UI.AutomationTests.csproj

# Firefox
$env:BROWSER="Firefox"
dotnet test UI.AutomationTests/UI.AutomationTests.csproj

# Edge
$env:BROWSER="Edge"
dotnet test UI.AutomationTests/UI.AutomationTests.csproj

Test Categories

# Smoke tests only
dotnet test --filter "Category=Smoke"

# Performance tests
dotnet test --filter "Category=Performance"

# Cross-browser tests
dotnet test --filter "Category=Cross-Browser"

Docker Execution

Build and Run Container

# Build Docker image
docker build -t test-automation-framework:latest .

# Run tests in container
docker run --rm test-automation-framework:latest

# Run with volume mounts for results
docker run --rm \
  -v ${PWD}/TestResults:/app/TestResults \
  -v ${PWD}/logs:/app/logs \
  -v ${PWD}/Screenshots:/app/Screenshots \
  test-automation-framework:latest

πŸ“Š Test Reporting

Generated Artifacts

  • TRX Files: Visual Studio test result format
  • Coverage Reports: Code coverage analysis
  • Screenshots: Failure evidence for UI tests
  • Logs: Detailed execution traces
  • HTML Reports: Human-readable test summaries

Viewing Results

# View test results
Start-Process ./TestResults/test-results.trx

# Open log files
Get-Content ./logs/test-log-*.txt | Out-GridView

# Browse screenshots
Invoke-Item ./Screenshots/

πŸ”§ Configuration

Browser Configuration

Modify appsettings.json to customize browser behavior:

{
  "BrowserSettings": {
    "Chrome": {
      "Arguments": [
        "--no-sandbox",
        "--disable-dev-shm-usage",
        "--window-size=1920,1080"
      ]
    }
  }
}

Test Environment Settings

Configure different environments for test execution:

{
  "Environment": {
    "CurrentEnvironment": "Development",
    "Environments": {
      "Development": {
        "BaseUrl": "https://dev.example.com"
      },
      "Staging": {
        "BaseUrl": "https://staging.example.com"
      }
    }
  }
}

πŸ”„ CI/CD Pipeline

GitHub Actions Features

  • Multi-Browser Testing: Parallel execution across Chrome and Firefox
  • API Testing: Comprehensive REST API validation
  • Container Testing: Docker-based test execution
  • Artifact Collection: Test results, logs, and screenshots
  • Scheduled Runs: Daily regression testing
  • Performance Monitoring: Baseline performance validation

Pipeline Triggers

  • Push to main/develop branches
  • Pull requests to main
  • Daily scheduled runs (6 AM UTC)
  • Manual execution with [perf] commit message

Viewing Pipeline Results

  1. Navigate to GitHub repository
  2. Click "Actions" tab
  3. Select latest workflow run
  4. Download artifacts for detailed results

πŸ“ˆ Test Categories

Smoke Tests

Quick validation of core functionality

[Test]
[Category("Smoke")]
public void GoogleHomePage_ShouldLoadSuccessfully()

Functional Tests

Comprehensive feature testing

[Test]
[Category("Functional")]
[TestCase("Selenium WebDriver")]
public void GoogleSearch_ShouldReturnRelevantResults(string searchTerm)

Performance Tests

Response time and load validation

[Test]
[Category("Performance")]
public void GoogleSearch_ShouldCompleteWithinTimeLimit()

Cross-Browser Tests

Multi-browser compatibility validation

[Test]
[Category("Cross-Browser")]
public void GoogleSearch_ShouldWorkAcrossBrowsers()

πŸ› Troubleshooting

Common Issues

WebDriver Issues

# Update Chrome driver
dotnet add package Selenium.WebDriver.ChromeDriver --prerelease

# Check Chrome version compatibility
chrome --version

Network Issues

# Test API connectivity
curl https://jsonplaceholder.typicode.com/posts/1

# Check proxy settings
$env:HTTP_PROXY=""
$env:HTTPS_PROXY=""

Permission Issues

# Set execution policy for scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

πŸ“š Best Practices

Page Object Model

  • Encapsulate page interactions in dedicated classes
  • Use meaningful element locators
  • Implement wait strategies for dynamic content

API Testing

  • Validate both positive and negative scenarios
  • Test error handling and edge cases
  • Verify response schemas and data integrity

Test Design

  • Keep tests atomic and independent
  • Use descriptive test names and categories
  • Implement proper setup and teardown

CI/CD Integration

  • Run tests in multiple environments
  • Collect comprehensive artifacts
  • Set up notifications for failures

🀝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/new-test-suite
  3. Commit changes: git commit -am 'Add new test suite'
  4. Push to branch: git push origin feature/new-test-suite
  5. Submit pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

  • Create GitHub issues for bugs and feature requests
  • Check existing documentation and troubleshooting guides
  • Review CI/CD pipeline logs for execution details

Built with ❀️ for Quality Engineering

This framework demonstrates modern test automation practices suitable for enterprise-level applications and serves as a foundation for scalable, maintainable test automation solutions.

About

Test Automation Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published