Skip to content

Commit

Permalink
Add end-to-end Pester unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed Jun 28, 2022
1 parent 8738797 commit 4bb9108
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .vsts-ci/templates/ci-general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ steps:
displayName: PowerShell version
inputs:
targetType: inline
script: $PSVersionTable
script: |
$PSVersionTable
Get-Module -ListAvailable Pester
pwsh: ${{ parameters.pwsh }}

- task: UseDotNet@2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
Expand Down Expand Up @@ -294,5 +294,31 @@ public async Task CanLaunchScriptWithCommentedLastLineAsync()

Assert.Collection(GetLog(), (i) => Assert.Equal("a log statement", i));
}

[Fact]
public async Task CanRunPesterTestFile()
{
string logStatement = GenerateScriptFromLoggingStatements("works");
string filePath = NewTestFile(@"
Describe 'A' {
Context 'B' {
It 'C' {
throw 'error'
}
It 'D' {
" + logStatement + @"
}
}
}
");

await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(false);

ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(false);
Assert.NotNull(configDoneResponse);
await Task.Delay(5000).ConfigureAwait(false);

Assert.Collection(GetLog(), (i) => Assert.Equal("works", i));
}
}
}

0 comments on commit 4bb9108

Please sign in to comment.