Skip to content

Tests checking for Alias presence/behaviour no longer check appropriately #17310

@KingAl

Description

@KingAl

Summary of the new feature / enhancement

It looks like aliases were removed from the Pester test scripts in #8546 in an automated fashion, which is generally a good hygienic step (and suppresses complaints from linters), except that some of these tests were checking for the presence and behaviour of aliases themselves.
For example, one test in GroupObject.Tests.ps1 begins -

It "Should have the same output between the group alias and the group-object cmdlet" {
        $actualAlias = Group-Object -InputObject $testObject
        $actualCmdlet = Group-Object -InputObject $testObject

And then goes on to compare the results - but it's no longer doing a meaningful comparison.

Proposed technical implementation details (optional)

It makes some sense for the test to check for default aliases - it's effectively enforcing the 'default interface' to a given utility.
However, if Aliases are known to work correctly after build, i.e. by checking that functionality elsewhere, we probably don't need to check the actual behaviour.
In that case, the test suite could just check for the presence of the alias, e.g.

It "should have the Group alias" {
  $aliasCommand = (Get-Alias Group).ResolvedCommand
  $actualCommand = (Get-Command Group-Object)
  $aliasCommand | Should -Be $actualCommand
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreWG-Quality-Testissues in a test or in test infrastructure

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions