What problem does it solve?
Writing tests for OrchardCore requires knowing its specific conventions: xUnit v3 with the Microsoft Testing Platform, the SiteContext tenant harness for integration tests, Moq for mocking services, and Playwright for browser tests. This Skill guides you through choosing the right test type and writing it correctly the first time.
Core Features & Use Cases
- Unit Tests: Create xUnit test classes with proper naming conventions, [Fact]/[Theory] attributes, and Moq-based mocking of OrchardCore services like IClock and IShellHost.
- Integration Tests: Spin up real tenants with SiteContext, run recipes, call content APIs over HttpClient, and resolve tenant services inside UsingTenantScopeAsync.
- Functional Tests: Drive a headless Chromium browser against a running CMS instance using OrchardTestFixture and Playwright, with optional trace capture.
- Use Case: You added a new content API endpoint and need an integration test. The Skill shows you how to initialize a SiteContext with the Blog recipe, post a draft content item, and assert on the response.
Quick Start
Write an integration test using SiteContext that creates a draft content item through the content API and verifies it is not published.