Skip to content

Replace Should -Not -Throw with direct invocation in all test files #2275

@coderabbitai

Description

@coderabbitai

Description

Throughout the project's test files, there are instances where commands are wrapped with assertions. According to the project's coding guidelines, this pattern should be avoided.

Current Issue

Tests currently use patterns like:

{
    Some-Command -ErrorAction 'Stop'
} | Should -Not -Throw

Required Change

Replace with direct invocation:

$null = Some-Command -ErrorAction 'Stop'

Scope

This affects all test files matching the pattern:

  • tests/Unit/**/*.Tests.ps1
  • tests/Integration/**/*.Integration.Tests.ps1

Guidelines Reference

From the project's test guidelines: "Do not use Should -Not -Throw; invoke commands directly"

Background

This issue was identified during review of PR #2245 where the pattern was found in the new integration test file tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1.

Backlinks

Metadata

Metadata

Assignees

Labels

testsThe issue or pull request is about tests only.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions