Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pester v5 #366

Merged
merged 49 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fd6eb6a
Update GitHubUsers.tests.ps1 for Pester v5
tigerfansga Apr 25, 2022
5fe9981
Update GitHubAnalytics.tests.ps1 for Pester v5
tigerfansga Apr 25, 2022
64d9137
Update GitHubAssignees.tests.ps1 for PesterV5
tigerfansga Apr 26, 2022
10f9327
Update GitHubBranches.tests.ps1 for Pester v5
tigerfansga Apr 27, 2022
c308af8
Update GitHubContents.tests.ps1 for Pester v5
tigerfansga Apr 27, 2022
c221a8c
Update GitHubCore.tests.ps1 for Pester v5
tigerfansga Apr 27, 2022
3148d70
Update GitHubEvents.tests.ps1 for Pester v5
tigerfansga Apr 27, 2022
e908923
Update GitHubGistComments.tests.ps1 for Pester v5
tigerfansga May 1, 2022
a24d11a
Update GitHubGists.tests.ps1 for Pester v5
tigerfansga May 2, 2022
1bfcaa5
Update GitHubGraphQl.tests.ps1 for Pester v5
tigerfansga May 2, 2022
232e574
Update GitHubIssueComments.tests.ps1 for Pester v5
tigerfansga May 9, 2022
72e0c72
Update GitHubIssues.tests.ps1 for Pester v5
tigerfansga May 10, 2022
cc7cfc9
Update GitHubLabels.tests.ps1 for Pester v5
tigerfansga May 12, 2022
f8b3464
Update GitHubMilestones.tests.ps1 for Pester v5
tigerfansga May 12, 2022
bfc81d8
Update GitHubOrganizations.tests.ps1 for Pester v5
tigerfansga May 13, 2022
d98f1fa
Update GitHubProjectCards.tests.ps1 for Pester v5
tigerfansga May 13, 2022
79fae40
Update GitHubProjectColumns.tests.ps1 for Pester v5
tigerfansga May 13, 2022
f038807
Update GitHubProjects.tests.ps1 for Pester v5
tigerfansga May 13, 2022
dc7a64b
Update GitHubPullRequests.tests.ps1 for Pester v5
tigerfansga May 13, 2022
a22277d
Update GitHubReactions.tests.ps1 for Pester v5
tigerfansga May 13, 2022
295c034
Remove repository code of conduct tests from GitHubMiscellaneous.test…
tigerfansga May 16, 2022
20423c3
Update GitHubReleases.tests.ps1 to account for pre-releases
tigerfansga May 16, 2022
d1006a1
Update GitHubReleases.tests.ps1 for Pester v5
tigerfansga May 21, 2022
be4cd2c
Update GitHubRepositories.tests.ps1 for Pester v5
tigerfansga Jul 20, 2022
af82bf8
Update GitHubRepositoryForks.tests.ps1 for Pester v5
tigerfansga Jul 21, 2022
39eccbe
Update GitHubRepositoryTraffic.tests.ps1 for Pester v5
tigerfansga Jul 21, 2022
72f7502
Update GitHubTeams.tests.ps1 for Pester v5
tigerfansga Jul 21, 2022
07fdf53
Update file formating
tigerfansga Sep 22, 2022
3bb93c4
Merge branch 'master' into PesterV5
tigerfansga Sep 22, 2022
09a6244
Update CONTRIBUTING.md
tigerfansga Sep 22, 2022
1b7ebc0
Update run-unitTests.yaml to install Pester v5.3.3
tigerfansga Sep 22, 2022
dbda33b
Update CONTRIBUTING.md for Pester v5
tigerfansga Sep 27, 2022
3225a4d
Merge branch 'master' into PesterV5
HowardWolosky Dec 15, 2022
371b740
Remove trailing spaces
HowardWolosky Dec 15, 2022
2b47b43
Update GitHubBranches.tests.ps1
HowardWolosky Dec 15, 2022
9e34ade
Merge branch 'master' into PesterV5
HowardWolosky Dec 16, 2022
3a24ab4
Update GitHubRepositories.tests.ps1
HowardWolosky Dec 16, 2022
e59a380
Merge branch 'master' into PesterV5
HowardWolosky Dec 16, 2022
619ca51
Update settings.json
HowardWolosky Dec 16, 2022
40891ca
Apply suggestions from code review
HowardWolosky Dec 16, 2022
587ece4
Apply suggestions from code review
HowardWolosky Dec 16, 2022
f85bfc9
Update GitHubProjects.tests.ps1
HowardWolosky Dec 16, 2022
2a9e13d
Update GitHubProjectColumns.tests.ps1
HowardWolosky Dec 16, 2022
fd964ca
Update GitHubProjectCards.tests.ps1
HowardWolosky Dec 16, 2022
9d0c6bc
Update run-unitTests.yaml
HowardWolosky Dec 16, 2022
c69f24f
Update build/pipelines/templates/run-unitTests.yaml
HowardWolosky Dec 16, 2022
2957287
Update GitHubContents.tests.ps1
HowardWolosky Dec 16, 2022
0616f29
Update GitHubIssueComments.tests.ps1
HowardWolosky Dec 16, 2022
41d44e9
Update run-unitTests.yaml
HowardWolosky Dec 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"files.trimTrailingWhitespace": true
},
"powershell.codeFormatting.openBraceOnSameLine": false,
"powershell.codeFormatting.alignPropertyValuePairs": false
}
"powershell.codeFormatting.alignPropertyValuePairs": false,
"powershell.pester.useLegacyCodeLens": false
}
21 changes: 15 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ This module supports testing using the [Pester UT framework](https://github.com/
To install it:

```powershell
Install-Module -Name Pester -RequiredVersion 4.10.1 -AllowClobber -SkipPublisherCheck -Force
Install-Module -Name Pester -MinimumVersion 5.3.3 -AllowClobber -SkipPublisherCheck -Force
```

#### Configuring Your Environment
Expand Down Expand Up @@ -421,21 +421,29 @@ Please keep in mind some tests may fail on your machine, as they test private it
Pester can also be used to test code-coverage, like so:

```powershell
Invoke-Pester -CodeCoverage "$root\GitHubLabels.ps1" -TestName "*"
$pesterConfig = New-PesterConfiguration
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
$pesterConfig.CodeCoverage.Enabled = $true

Invoke-Pester -Configuration $pesterConfig
# Be sure you're not passing this in to -PesterOption, since that's different than the configuration.
```

This command tells Pester to check the `GitHubLabels.ps1` file for code-coverage.
The `-TestName` parameter tells Pester to run any `Describe` blocks with a `Name` like
`"*"` (which in this case, is every test, but can be made more specific).

The code-coverage object can be captured and interacted with, like so:

```powershell
$cc = (Invoke-Pester -CodeCoverage "$root\GitHubLabels.ps1" -TestName "*" -PassThru -Quiet).CodeCoverage
$pesterConfig = New-PesterConfiguration
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
$pesterConfig.CodeCoverage.Enabled = $true
$pesterConfig.Run.PassThru = $true

$cc = (Invoke-Pester -Configuration $pesterConfig).CodeCoverage
```

There are many more nuances to code-coverage, see
[its documentation](https://github.com/pester/Pester/wiki/Code-Coverage) for more details.
[its documentation](https://pester.dev/docs/usage/code-coverage) for more details.

#### Automated Tests
[![Build status](https://dev.azure.com/ms/PowerShellForGitHub/_apis/build/status/PowerShellForGitHub-CI?branchName=master)](https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master)
Expand Down Expand Up @@ -615,6 +623,7 @@ Thank you to all of our contributors, no matter how big or small the contributio
- **[Christoph Bergmeister (@bergmeister)](https://github.com/bergmeister)**
- **[Simon Heather (@X-Guardian)](https://github.com/X-Guardian)**
- **[Neil White (@variableresistor)](https://github.com/variableresistor)**
- **[Mark Curole(@tigerfansga)](https://github.com/tigerfansga)**

----------

Expand Down
4 changes: 2 additions & 2 deletions Tests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $script:originalConfigFile = $null

function Initialize-CommonTestSetup
{
<#
<#
.SYNOPSIS
Configures the tests to run with the authentication information stored in the project's
Azure DevOps pipeline (if that information exists in the environment).
Expand All @@ -38,7 +38,7 @@ function Initialize-CommonTestSetup
This method is invoked immediately after the declaration.
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification="Needed to configure with the stored, encrypted string value in Azure DevOps.")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "Needed to configure with the stored, encrypted string value in Azure DevOps.")]
param()

$script:moduleName = 'PowerShellForGitHub'
Expand Down
19 changes: 9 additions & 10 deletions Tests/GitHubAnalytics.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@

[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '',
Justification='Suppress false positives in Pester code blocks')]
Justification = 'Suppress false positives in Pester code blocks')]
param()

# This is common test code setup logic for all Pester test files
$moduleRootPath = Split-Path -Path $PSScriptRoot -Parent
. (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Common.ps1')

try
{
# TODO
BeforeAll {
# This is common test code setup logic for all Pester test files
$moduleRootPath = Split-Path -Path $PSScriptRoot -Parent
. (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Common.ps1')
}
finally
{

# TODO

AfterAll {
if (Test-Path -Path $script:originalConfigFile -PathType Leaf)
{
# Restore the user's configuration to its pre-test state
Expand Down
Loading