exp-mock-usage-analysis

Solid

Audits .NET test mock usage by tracing each mock setup through the production code's execution path to find dead, unreachable, redundant, or replaceable mocks. Use when the user asks to audit mock usage, find unused or unnecessary mock setups, check if mocks are needed, reduce mock duplication or over-mocking, simplify test setup, or review whether mock configurations like ILogger/IOptions should use real implementations instead. Supports Moq, NSubstitute, and FakeItEasy.

Testing & QA 3,219 stars 238 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Mock Usage Analysis Trace each mock setup through the production code's execution path to determine which setups are actually exercised at runtime and which are dead, unreachable, redundant, or replaceable with real implementations. ## When to Use - User asks to audit, review, or analyze mock usage in .NET tests - User wants to find unused, unnecessary, or redundant mock setups - User wants to simplify test setup or reduce over-mocking - User asks whether mocks of ILogger, IOptions, or similar types are needed ## When Not to Use - User wants to write new mocks or tests (general testing guidance) - User wants to detect non-mock test anti-patterns (use `test-anti-patterns`) - User wants to migrate between mock frameworks (out of scope) ## Inputs | Input | Required | Description | |-------|----------|-------------| | Test code | Yes | Test files to analyze | | Production code | Yes | Code under test — essential for tracing execution paths | ## Workflow ### Step 1: Read all provided code Read the test files and **always** read the production code. You cannot determine whether a mock setup is necessary without understanding the production method's control flow. Identify the mock framework by scanning for its patterns: - **Moq**: `new Mock<T>()`, `.Setup(...)`, `.Verify(...)` - **NSubstitute**: `Substitute.For<T>()`, `.Returns(...)`, `.Received(...)` - **FakeItEasy**: `A.Fake<T>()`, `A.CallTo(...)`, `.MustHaveHappened()` Use the correct framework's terminology through...

Details

Author
dotnet
Repository
dotnet/skills
Created
3 months ago
Last Updated
today
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

Testing & QA Solid

exp-test-maintainability

Detects duplicate boilerplate, copy-paste tests, and structural maintainability issues across .NET test suites. Use when the user asks to reduce repetition, consolidate similar test methods, convert copy-paste tests to data-driven parameterized tests, suggest a better test structure, or identify refactoring opportunities. Identifies repeated construction, assertion patterns, copy-paste methods convertible to DataRow/Theory/TestCase, redundant setup/teardown, and shared infrastructure. Produces an analysis report with concrete before/after suggestions. Works with MSTest, xUnit, NUnit, and TUnit. DO NOT USE FOR: writing new tests (use writing-mstest-tests), reviewing test quality or anti-patterns (use test-anti-patterns), or deep mock auditing (use exp-mock-usage-analysis).

3,219 Updated today
dotnet
Testing & QA Solid

test-anti-patterns

Quick pragmatic review of .NET test code for anti-patterns that undermine reliability and diagnostic value. Use when asked to review tests, find test problems, check test quality, or audit tests for common mistakes. Catches assertion gaps, flakiness indicators, over-mocking, naming issues, and structural problems with actionable fixes. Use for periodic test code reviews and PR feedback. For a deep formal audit based on academic test smell taxonomy, use exp-test-smell-detection instead. Works with MSTest, xUnit, NUnit, and TUnit.

3,219 Updated today
dotnet
Testing & QA Solid

test-quality-analysis

Detect test smells, overmocking, flaky tests, and coverage issues. Analyze test effectiveness, maintainability, and reliability. Use when reviewing tests or improving test quality.

162 Updated 2 weeks ago
secondsky
Testing & QA Solid

api-testing-observability-api-mock

You are an API mocking expert specializing in realistic mock services for development, testing, and demos. Design mocks that simulate real API behavior and enable parallel development.

39,350 Updated today
sickn33
Testing & QA Listed

api-testing-observability-api-mock

You are an API mocking expert specializing in realistic mock services for development, testing, and demos. Design mocks that simulate real API behavior and enable parallel development.

335 Updated today
aiskillstore