{"slug":"scaffold-dotnet-test-project","title":"scaffold-dotnet-test-project","summary":"Create the first .NET test project. USE FOR: \"solution has no tests\", xUnit tests, Tests.csproj/ProjectReference, add an omitted test project to .sln/.slnx/.slnf, central packages, or tests missing from CI. DO NOT USE FOR: a suitable project already registered in the requested bu","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-24T05:37:33.973866Z","repo":{"url":"https://github.com/dotnet/skills","stars":6296,"forks":500,"license":"MIT","updatedAt":"2026-11-19T18:23:42Z"},"bodyHtml":"<hr>\n<h2>name: scaffold-dotnet-test-project\ndescription: &gt;-\nCreate the first .NET test project. USE FOR: \"solution has no tests\",\nxUnit tests, Tests.csproj/ProjectReference, add an omitted test project to\n.sln/.slnx/.slnf, central packages, or tests missing from CI. DO NOT USE FOR:\na suitable project already registered in the requested build entry point\n(stop) or migration.\nlicense: MIT</h2>\n<h1>Scaffold a .NET Test Project</h1>\n<p>Create the smallest test project that fits the repository's existing build and\ntest conventions, wire it to the correct production project and build entry\npoint, and prove solution-level test discovery sees it. This skill scaffolds the\ncontainer for tests; it does not invent a solution-wide test architecture.</p>\n<h2>When to Use</h2>\n<ul>\n<li>A .NET solution or project has production code but no suitable test project.</li>\n<li>A user asks to \"set up tests\" or \"add a test project\" from a vague starting point.</li>\n<li>Tests pass when the new <code>.csproj</code> is targeted directly but CI cannot discover it.</li>\n<li>A multi-project solution needs a bounded test project for one production project.</li>\n</ul>\n<h2>When Not to Use</h2>\n<ul>\n<li>A compatible test project already references the target production project.\nReuse it and continue with <code>code-testing-agent</code>.</li>\n<li>The request is specifically about authoring or modernizing MSTest test code.\nUse <code>writing-mstest-tests</code> after the project exists.</li>\n<li>The repository's current build is broken for an unrelated reason. Report that\nblocker; do not redesign project structure to hide it.</li>\n<li>The user asks to migrate xUnit, NUnit, MSTest, TUnit, VSTest, or MTP.</li>\n</ul>\n<h2>Inputs</h2>\n<table>\n<thead>\n<tr>\n<th>Input</th>\n<th>Required</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Repository or solution path</td>\n<td>No</td>\n<td>Discover from the current workspace when omitted</td>\n</tr>\n<tr>\n<td>Production project</td>\n<td>No</td>\n<td>Infer the narrowest project in the requested scope</td>\n</tr>\n<tr>\n<td>Test framework</td>\n<td>No</td>\n<td>Use an explicit choice; otherwise infer repository convention</td>\n</tr>\n<tr>\n<td>Build entry point</td>\n<td>No</td>\n<td>Existing <code>.sln</code>, <code>.slnx</code>, <code>.slnf</code>, or project graph used by CI</td>\n</tr>\n</tbody>\n</table>\n<h2>Workflow</h2>\n<h3>Step 1: Establish the repository contract</h3>\n<p>Inspect only the files needed to answer these questions:</p>\n<ol>\n<li>Which production project is in scope?</li>\n<li>What command does CI or the repository use to build and test?</li>\n<li>Does a suitable test project already reference that production project?</li>\n<li>Which test framework and runner do neighboring test projects use?</li>\n<li>Are package versions centrally managed by <code>Directory.Packages.props</code>,\n<code>Directory.Build.props</code>, <code>global.json</code>, or an MSBuild SDK declaration?</li>\n<li>Which target framework(s) must the test project compile against?</li>\n</ol>\n<p>Treat a test project as suitable only when its target framework can reference the\nproduction project and its purpose matches the requested layer. Do not create a\nsecond test project merely because its name differs from your preferred name.</p>\n<p><strong>No-op stop condition:</strong> when a suitable project already exists and is registered\nin the requested build entry point, do not repair, normalize, convert, or replace\nthe solution. If the user did not ask for tests yet, report the existing project\npath and stop with the workspace byte-for-byte unchanged.</p>\n<h3>Step 2: Choose one bounded project</h3>\n<p>Default to one test project per production project, named according to repository\nconvention (<code>Foo.Tests</code>, <code>Foo.UnitTests</code>, and so on). For a vague multi-project\nrequest, start with the project that owns the user-visible behavior or has the\nhighest-value untested logic; do not create one test project per source project\nwithout evidence that the repository wants that layout.</p>\n<p>Match, in order:</p>\n<ol>\n<li>The user's explicit framework choice.</li>\n<li>Existing test projects in the same repository.</li>\n<li>Repository-wide package/SDK conventions.</li>\n<li>A standard SDK template only when the repository provides no convention.</li>\n</ol>\n<p>Never mix frameworks in one test project. Never add package versions directly\nwhen central package management supplies them.</p>\n<h3>Step 3: Scaffold and reference the target</h3>\n<p>Use the matching <code>dotnet new</code> template (<code>xunit</code>, <code>nunit</code>, or <code>mstest</code>) rather than\nhand-writing template boilerplate. Then make only the repository-specific edits:</p>\n<ol>\n<li>Align target framework, nullable, implicit-usings, runner, and package style.</li>\n<li>Add a <code>ProjectReference</code> to each production project directly exercised by\nthe planned tests. Do not reference every project in the solution.</li>\n<li>Remove template sample tests that do not test repository behavior.</li>\n</ol>\n<p>For xUnit v3 projects that the repository runs through <code>dotnet test</code>, preserve or\nadd both:</p>\n<pre><code>&lt;OutputType&gt;Exe&lt;/OutputType&gt;\n&lt;TestingPlatformDotnetTestSupport&gt;true&lt;/TestingPlatformDotnetTestSupport&gt;\n</code></pre>\n<p><code>OutputType=Exe</code> alone makes the self-hosted runner work with <code>dotnet run</code>; it is\nnot evidence that the repository's <code>dotnet test</code> command can discover the tests.</p>\n<p>Prefer <code>dotnet add &lt;test-project&gt; reference &lt;production-project&gt;</code> for project\nreferences. Inspect the resulting project file before continuing.</p>\n<h3>Step 4: Register with the real build entry point</h3>\n<p>Creating a <code>.csproj</code> is not enough. Add it to the exact solution artifact used by\nthe repository:</p>\n<ul>\n<li><code>.sln</code> or <code>.slnx</code>: <code>dotnet sln &lt;solution&gt; add &lt;test-project&gt;</code></li>\n<li><code>.slnf</code>: add the project to the underlying solution and include it in the\nfilter used by the requested/CI test command.</li>\n<li>No solution artifact: keep the existing project-oriented workflow. Do not\ncreate a solution solely for aesthetics unless the user asked for one.</li>\n</ul>\n<p>Do not substitute a different solution file because it is easier to edit.</p>\n<h3>Step 5: Add a real smoke test</h3>\n<p>Replace template examples with the <strong>smallest smoke suite requested</strong>. The tests\nmust:</p>\n<ul>\n<li>instantiate or invoke a real symbol from the referenced production project;</li>\n<li>assert a concrete result, not only non-null/truthiness;</li>\n<li>avoid network, wall-clock, process, and real filesystem dependencies.</li>\n</ul>\n<p>These tests prove the project reference and discovery path. Stop after every\nbehavior explicitly named by the user is covered; extra boundary permutations\nare out of scope here and belong to <code>code-testing-agent</code>.</p>\n<h3>Step 6: Verify direct and harness-level execution</h3>\n<p>Run, in this order:</p>\n<ol>\n<li><code>dotnet test &lt;test-project&gt;</code> to isolate scaffolding failures.</li>\n<li>The repository's solution/root test command to prove CI discovery.</li>\n<li>A solution/project listing command to confirm the new project is registered.</li>\n</ol>\n<p>If the direct command passes but the harness-level command discovers no new\ntest, the scaffolding is incomplete. Fix registration before reporting success.\nDo not claim success from <code>dotnet build</code> alone.</p>\n<h2>Output Contract</h2>\n<p>Report a compact table:</p>\n<table>\n<thead>\n<tr>\n<th>Requirement</th>\n<th>Evidence</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Test project created/reused</td>\n<td>Project path</td>\n</tr>\n<tr>\n<td>Production reference</td>\n<td>Referenced <code>.csproj</code> path</td>\n</tr>\n<tr>\n<td>Build registration</td>\n<td><code>.sln</code>/<code>.slnx</code>/<code>.slnf</code> entry or project-oriented command</td>\n</tr>\n<tr>\n<td>Test discovery</td>\n<td>Passing harness-level command and discovered test</td>\n</tr>\n</tbody>\n</table>\n<p>If validation is blocked, report the exact failing command and first actionable\nerror. Do not describe an unrun command as successful.</p>\n<h2>Validation</h2>\n<ul>\n<li><input disabled=\"disabled\" type=\"checkbox\"> A suitable existing test project was ruled out before creating another.</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Framework, runner, target framework, and package style match the repository.</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Project references cover only the production projects under test.</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Central package management was preserved.</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Template sample tests were removed.</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> At least one real deterministic test asserts a concrete behavior.</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> The test project passes directly.</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> The repository's solution/root command discovers and runs the new test.</li>\n</ul>\n<h2>Common Pitfalls</h2>\n<table>\n<thead>\n<tr>\n<th>Pitfall</th>\n<th>Corrective action</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Creating a project that CI never sees</td>\n<td>Register it with the exact solution/filter used by CI and run that command</td>\n</tr>\n<tr>\n<td>Picking a favorite framework</td>\n<td>Infer the repository convention before using a default</td>\n</tr>\n<tr>\n<td>Adding package versions under CPM</td>\n<td>Add versionless references and keep versions in <code>Directory.Packages.props</code></td>\n</tr>\n<tr>\n<td>Referencing the whole solution</td>\n<td>Reference only projects whose APIs the tests compile against</td>\n</tr>\n<tr>\n<td>Keeping <code>UnitTest1</code></td>\n<td>Replace it with a concrete test of repository behavior</td>\n</tr>\n<tr>\n<td>Creating parallel unit/integration projects from a vague ask</td>\n<td>Start with one bounded project; expand only for a demonstrated boundary</td>\n</tr>\n<tr>\n<td>Treating a green build as test discovery</td>\n<td>Run the harness-level test command and observe the test</td>\n</tr>\n</tbody>\n</table>\n","files":[{"path":"SKILL.md","sizeBytes":12346,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-10-16T00:43:14.662626Z","sha256":"B74AFEFB1FEE0C4DC3DBAE2DEE38645DAAE3AAC69F2172D302590201D66C39D4","sizeBytes":4910},"review":null,"source":{"repositoryUrl":"https://github.com/dotnet/skills","path":"plugins/dotnet-test/skills/scaffold-dotnet-test-project","license":"MIT","commit":"4e03bfdade5d1f9b7d1c2e95f64e31d1cb7af5ab","subtreeSha":"A9AFD51A5C060B9D91316170500275E28E938530D51E96C9E5F67F1713DCBF9B","lastSyncedAt":"2026-11-19T19:30:03.195544Z"},"reviewedAt":"2026-10-16T00:47:03.11223Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/dotnet/skills/tree/main/plugins/dotnet-test/skills/scaffold-dotnet-test-project"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install dotnet-skills@llmmart"},{"target":"git","command":"git clone https://github.com/dotnet/skills.git"}]}