Is there a recipe to use the --filter
option to include skipped tests, or do I need to edit the test suite to remove the Skip directive?
Similar topic to Run Xunit tests, that are marked "skip"
Is there a recipe to use the --filter
option to include skipped tests, or do I need to edit the test suite to remove the Skip directive?
Similar topic to Run Xunit tests, that are marked "skip"
I guess, the --filter
option can only be used, to exclude more tests, but not to include them.
I updated the PowerShell script of the referenced topic to also remove the skip-properties of F# and VB tests.
Just copy that code into your $profile file and use “dotnet testall” to run all tests
# catch call to exercism.exe
# this automatically changes the working folder
# when you download a new exercise
function exercism {
Param(
[string]$keyword = ""
)
# run exercism.exe with the given arguments
exercism.exe $keyword @args
# if keyword is "download", extract exercise and track and go to that folder
if ($keyword -eq "download") {
# get exercise
$exercise = (
$args |
where {$_.StartsWith("--exercise=")} |
select -First 1
).ToString().Substring(11)
# get track
$track = (
$args |
where {$_.StartsWith("--track=")} |
select -First 1
).ToString().Substring(8)
# go to that folder
cd $env:USERPROFILE\Exercism\$track\$exercise
}
}
# catch call to dotnet.exe
# adds command "dotnet testall"
# this lets you run all tests, even if they're marked "skip"
function dotnet {
Param(
[string]$keyword = ""
)
# if keyword = "testall", remove all skip parameters in first test file and run test
if ($keyword -eq "testall") {
$testFile = dir -File | where {[Regex]::IsMatch($_.Name, 'Tests\.(cs|fs|vb)$', "IgnoreCase")} | select -First 1
if ($testFile -eq $null) {throw "no test file found. Please check if you're in the exercise folder"}
$originalContent = Get-Content $testFile -Raw
# Depending on language, use different removement methods
# Removement is done with Regex, so the Skip properties will also be removed,
# if there's a different text attached to them
# !!ATTENTION!! : Doesn't work if a closing bracket is in the Skip-string
$regExPattern = switch ($testFile.Extension.ToLower()) {
".cs" {'(?i)(?<=\[Fact)\s*\(\s*Skip.*?\)'}
".fs" {'(?i)(?<=\[<Fact)\s*\(\s*Skip.*?\)'}
".vb" {'(?i)(?<=\<Fact)\s*\(\s*Skip.*?\)'}
}
$skipFreeContent = [Regex]::Replace($originalContent, $regExPattern, "")
# run "dotnet test" with the skip free file, then restore the original contents
Set-Content -Path $testFile.FullName -Value $skipFreeContent
try {
dotnet.exe test @args
} finally {
Set-Content -Path $testFile.FullName -Value $originalContent
}
} else {
# pass all other commands to dotnet.exe directly
dotnet.exe $keyword @args
}
}
I’m sorry, there is no such option.
I’m Linux user, so this is bash. My exercism test
function includes this:
jq -r '.files.test[]' .exercism/config.json \
| xargs perl -i -pe 's/\(Skip = .*?\)//'
dotnet test