Skip to content

[Tests] Multiple test files — Mock-only tests verify Moq dispatch, not production code #552

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Warning

Files:

  • tests/Servy.UI.UnitTests/Services/FileDialogServiceTests.cs
  • tests/Servy.UI.UnitTests/Services/MessageBoxServiceTests.cs
  • tests/Servy.UnitTests/Services/ServiceCommandsTests.cs (5 of 9 tests)

Description:
These tests call methods on _mockService.Object and immediately verify those same calls on _mockService. This tests Moq's internal dispatch table, not any production code. The tests will always pass regardless of whether the real implementation exists, compiles, or behaves correctly. Zero production code coverage is produced.

Example pattern:

_mockFileDialogService.Setup(x => x.OpenFile(...)).Returns("test.exe");
var result = _mockFileDialogService.Object.OpenFile(...);
_mockFileDialogService.Verify(x => x.OpenFile(...), Times.Once);

Suggested fix:
Instantiate the real production class and test its actual behavior, or delete the mock-only tests and replace with integration tests.

Metadata

Metadata

Assignees

Labels

testsChanges to test code and coverage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions