Notre avis
Exécute des tests TUnit avec Playwright dans un projet .NET, avec options de parallélisme, filtrage et génération de rapports.
Points forts
- Support du filtrage par classe, nom de test ou expression régulière via treenode-filter
- Gestion de la parallélisation pour éviter la surcharge système
- Rapports détaillés en console et format TRX
- Réduction de la flakyness avec reprises automatiques et exécution séquentielle
Limites
- Nécessite une configuration de projet spécifique (SummitUI.Tests.Playwright)
- Les filtres utilisent un format de chemin complexe (assembly/namespace/classe/test)
- Dépend de l'installation du SDK .NET
Lorsque vous devez exécuter une suite de tests Playwright dans un projet .NET TUnit, avec contrôle sur le parallélisme et le filtrage.
Pour des tests unitaires simples sans navigateur, préférez un framework plus léger comme xUnit ou NUnit sans Playwright.
Analyse de sécurité
SûrThe skill only provides instructions for running dotnet test commands and does not perform any destructive actions, external network calls, or exfiltration. No obfuscated or unsafe commands are present.
Aucun point d'attention détecté
Exemples
Run all TUnit Playwright tests with maximum 1 parallel test.Run all tests in the SelectAccessibilityTests class.Run the test named Trigger_ShouldHave_RoleCombobox.name: tunit description: Run TUnit tests with Playwright. Use when user asks to run tests, execute tests, or check if tests pass.
Running TUnit Tests
This project uses TUnit with Playwright for testing. Tests are located in tests/SummitUI.Tests.Playwright/.
Run All Tests
dotnet run --project tests/SummitUI.Tests.Playwright
Run Tests with Limited Parallelism (Recommended)
To prevent system overload when running Playwright tests, limit parallel test execution:
# Run with maximum 1 parallel test (sequential)
dotnet run --project tests/SummitUI.Tests.Playwright -- --maximum-parallel-tests 1
# Run with maximum 8 parallel tests
dotnet run --project tests/SummitUI.Tests.Playwright -- --maximum-parallel-tests 8
Run Tests with Filters
TUnit uses --treenode-filter with path pattern: /assembly/namespace/class/test
Filter by class name:
dotnet run --project SummitUI.Tests.Playwright -- --treenode-filter '/*/*/ClassName/*'
Filter by exact test name:
dotnet run --project SummitUI.Tests.Playwright -- --treenode-filter '/*/*/*/TestName'
Examples:
# Run all Select accessibility tests
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/*/SelectAccessibilityTests/*'
# Run specific test by name
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/*/*/Trigger_ShouldHave_RoleCombobox'
# Run tests matching pattern (wildcard in test name)
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/*/*/Keyboard*'
# Run all tests in namespace
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/SummitUI.Tests.Playwright/*/*'
Run Tests in Debug Mode
When a debugger is attached, Playwright will run in debug mode (PWDEBUG=1) automatically via the Hooks.cs setup.
View Test Output
Add --report flags for different output formats:
# Console output with details
dotnet run --project tests/SummitUI.Tests.Playwright -- --output-format console-detailed
# Generate TRX report
dotnet run --project tests/SummitUI.Tests.Playwright -- --report-trx
Flakiness Mitigation
The test project includes several features to reduce flakiness:
- Automatic Retries: Tests are automatically retried up to 2 times on failure (
[Retry(2)]in GlobalSetup.cs) - Fully Sequential Execution: All tests run sequentially via
[assembly: NotInParallel]in GlobalSetup.cs - Server Readiness Check:
Hooks.cswaits for the Blazor server to be fully ready before tests start - Extended Timeouts: Configured via
tunit.jsonfor longer test and hook timeouts
Project Structure
GlobalSetup.cs- Assembly-level test configuration (retries, parallelism)Hooks.cs- Test session setup/teardown (starts Blazor server)BlazorWebApplicationFactory.cs- WebApplicationFactory for hosting the test servertunit.json- TUnit configuration file*AccessibilityTests.cs- Accessibility test classes inheriting fromPageTest
Test Conventions
- Tests inherit from
TUnit.Playwright.PageTestto getPageaccess - Use
[Before(Test)]for per-test setup - Use
[Before(TestSession)]/[After(TestSession)]for session-wide setup - Access the running server via
Hooks.ServerUrl
TDD Red-Green-Refactor
Testing
Skill qui guide Claude a travers le cycle TDD complet.
Audit d'Accessibilité Web
Testing
Réalise un audit d'accessibilité web complet selon les normes WCAG.
Générateur de Tests UAT
Testing
Génère des cas de test d'acceptation utilisateur structurés et complets.