Create Test Project
This skill writes unit tests for C# code. Beforehand, if the target .NET project doesn't have a corresponding xUnit test project yet, it first creates one and sets it up with standard packages.
When to Use
- User asks to "write tests" for code in a project with no corresponding test project
- User asks to "add tests" and
{ProjectName}.UnitTests(or similar name) doesn't exist - User asks to "create a test project"
- If a similarly-named project is found, verify that the user still wants to create a new test project first.
Process
- Identify the project that needs tests (e.g.,
MyApp.Api) - Check if
{ProjectName}.UnitTestsexists (e.g.,MyApp.Api.UnitTests) - If not, run
create-test-project.ps1to scaffold the test project, placing it under the same solution as the target project and at the same level - Write tests following the conventions in
testing-strategy.md
Files
create-test-project.ps1— Creates and configures the test projecttesting-strategy.md— Testing conventions and naming
What the Script Does
- Creates new xUnit project named
{ProjectName}.UnitTests - Adds it to the solution
- Installs packages: AwesomeAssertions, NSubstitute, AutoFixture
- Adds project reference to the source project
- Runs a clean build to verify setup
After Creation
Once the project exists, write tests following testing-strategy.md conventions.