Dotnet unit test
Skill VirtoCommerce/vc-mcp-testing-module/.claude/skills/dotnet-unit-test
[Development] Reproduce a Virto Commerce backend bug as a failing xUnit test (red), then prove the fix turns it green — without modifying existing tests. Used by the fullstack-backend developer agent in the /qa-fix pipeline (Gate 2/G3).From its SKILL.md
npx -y skills add VirtoCommerce/vc-mcp-testing-module --skill dotnet-unit-testAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.2 KB, as published. Nobody here has run it
/dotnet-unit-test — Reproduce a bug as a failing xUnit test
Encode a confirmed bug (STR + root cause) as a new xUnit test that fails on current code, so the
fix has an objective red→green proof. This is Gate 2 of the auto-fix ladder
(.claude/rules/quality-gates.md).
When to use
- A backend bug in a
vc-module-*/vc-platformrepo has been routed and the source is checked out in.fix-workspace/<repo>/(viaci/lib/repo-router.tscheckoutForFix). - Before writing any production-code fix — the test comes first.
Steps
- Find the test project FIRST — it decides whether this run is viable at all:
Glob tests/**/*.csproj. Expect exactly one (e.g.tests/VirtoCommerce.InventoryModule.Tests/), but the name drifts: some repos use.Testsingular (pricing), andmarketingadds Benchmark projects you must ignore. Notests/+packages.config+net4xcsproj = a legacy module (e.g. vc-module-CyberSource, branchmaster) → BAIL-back (FIX_STATUS: FAILED, reason: legacy toolchain / no test harness). For vc-platform pick the ONE relevant test project (e.g.tests/VirtoCommerce.Platform.Core.Tests) — never rundotnet testat the platform root. - Read the test
.csprojbefore writing a line of test code. It tells you the available stack — typicallyxunit.v33.x + Moq 4.20.x; FluentAssertions 7.x is common but NOT universal (vc-module-customer has none — plainAssertthere). Use only what's already referenced; never add or bump a test package (and never to FluentAssertions 8+ — paid license). - Locate the seam. From the RCA,
Grep/Globthe responsible service / handler / policy / controller / resolver inVirtoCommerce.<Name>.Core/.Data/.Web(seeknowledge/architecture/vc-module-architecture.md§2). Verify the actual contract/field names — VC has many "wrong field name silently no-ops" traps. - Restore — with the audit opt-out. VC modules set
TreatWarningsAsErrors=true, so NuGet-audit warnings (NU1903 vulnerable transitive package) fail a vanilladotnet restoreeven on the unmodifieddevbranch. Append-p:NuGetAudit=falseto everydotnetcommand (CLI-only — never editDirectory.Build.propsor a csproj to suppress it):dotnet restore tests/VirtoCommerce.<Name>.Tests -p:NuGetAudit=false - Write a NEW test (
[Fact]/[Theory], Moq for collaborators) in the test project asserting the expected behavior. Name the class/method after the behavior + ticket (CouponDiscountTests.AppliesToPostTierAmount_VCST1234); repo convention is*Tests.cs/*UnitTests.cs. Seexunit-patterns.md. - Confirm RED — scoped and filtered, so the loop stays fast (~seconds after first build):
The new test must fail on current code. If it passes, the STR/RCA is wrong → re-investigate, do not proceed.dotnet test tests/VirtoCommerce.<Name>.Tests --nologo -p:NuGetAudit=false --filter "FullyQualifiedName~VCST1234" - Hand off to
/dotnet-fixto make it green.
Failure modes (seen on real checkouts — don't flounder)
| Symptom | Cause | Action |
|---|---|---|
error NU1903: Warning As Error on restore/build/test | NuGet audit + TreatWarningsAsErrors — happens on a CLEAN dev branch | -p:NuGetAudit=false on the command line; never edit build props |
| Any new compiler warning fails the build | TreatWarningsAsErrors=true in every module's Directory.Build.props | Fix the warning in YOUR new code; don't suppress |
Should() doesn't compile | Test project has no FluentAssertions (e.g. customer) | Use plain xUnit Assert; don't add the package |
| New test passes immediately | STR/RCA doesn't match the code path | Re-investigate the seam; a "red" you never saw is not a repro |
| Huge test run / unrelated failures | Ran dotnet test at repo root of vc-platform | Scope to the single relevant test project |
Old-style csproj, packages.config, net4.x | Legacy module (CyberSource-era) | BAIL-back — different toolchain, out of auto-fix scope |
Hard rules
- Only ADD tests. Never edit or delete an existing test to reproduce or to pass (Gate 3). An existing test that breaks after the fix = contract conflict → STOP.
- No test harness? If the module has no test project, BAIL-back (
FIX_STATUS: FAILED, reason: no test harness) rather than scaffolding a risky one. - Trivial-skip: a one-line null-guard / typo / off-by-one with no behavioral branch may skip the dedicated repro test — note "trivial — covered by existing suite" in the PR body (Gate 2 via skip).
References
xunit-patterns.md— verified test stack + xUnit/Moq recipes for VC services/handlers/resolversknowledge/architecture/vc-module-architecture.md— repo layout, build/test profiles.claude/rules/quality-gates.md— G2 (red), G3 (green + existing tests untouched)- Build/test commands:
REPO_PROFILESinci/lib/repo-router.ts