Skip to content

Commit b13bef1

Browse files
glennsartirjmholt
authored andcommitted
[Ignore] Add Xunit Trait Filter (#818)
Previously when running tests all test would need to be run, however when this can take a while. This commit adds an option to add a trait filter to XUnit as per the Xunit documentation [1]. Later commits may add the actual trait attributes to the tests. [1] https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
1 parent 729711a commit b13bef1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

PowerShellEditorServices.build.ps1

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ param(
1111

1212
[string]$ModulesJsonPath = "$PSScriptRoot/modules.json",
1313

14-
[string]$DefaultModuleRepository = "PSGallery"
14+
[string]$DefaultModuleRepository = "PSGallery",
15+
16+
[string]$TestFilter = ''
1517
)
1618

1719
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}
@@ -223,24 +225,29 @@ function UploadTestLogs {
223225
}
224226
}
225227

228+
function XunitTraitFilter {
229+
# Reference https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
230+
if ($TestFilter) { "-trait $TestFilter" } else { "" }
231+
}
232+
226233
task Test TestServer,TestProtocol
227234

228235
task TestServer -If { !$script:IsUnix } {
229236
Set-Location .\test\PowerShellEditorServices.Test\
230237
exec { & $script:dotnetExe build -c $Configuration -f net452 }
231-
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild }
238+
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (XunitTraitFilter) }
232239
}
233240

234241
task TestProtocol -If { !$script:IsUnix } {
235242
Set-Location .\test\PowerShellEditorServices.Test.Protocol\
236243
exec { & $script:dotnetExe build -c $Configuration -f net452 }
237-
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild }
244+
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (XunitTraitFilter) }
238245
}
239246

240247
task TestHost -If { !$script:IsUnix } {
241248
Set-Location .\test\PowerShellEditorServices.Test.Host\
242249
exec { & $script:dotnetExe build -c $Configuration -f net452 }
243-
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild }
250+
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (XunitTraitFilter) }
244251
}
245252

246253
task CITest ?Test, {

0 commit comments

Comments
 (0)