I often find myself in a situation, when I cannot express my intention with a pester test.
By express I mean: person who see failed test results should understand what's the matter of failure with the least possible actions.
For example, let's take some binary condition.
Let's say these are my functions:
function Get-SmartFoo() {
sleep 2
'foo'
}
function Get-DumbFoo() {
sleep 1
'foo'
}
I want to express: Get-SmartFoo should work faster then Get-DumbFoo (which is currently not true).
Here is what I can write:
Describe 'SmartFoo' {
It 'Return string foo' {
Get-SmartFoo | Should be 'foo'
}
It 'faster then DumbFoo' {
$smartFooTime = (Measure-Command { Get-SmartFoo }).TotalSeconds
$dumbFooTime = (Measure-Command { Get-DumbFoo }).TotalSeconds
$smartFooTime -lt $dumbFooTime | Should Be $true
}
}

Imagine, you didn't touch test code for a while. Probably, you will go to the source and find the line 20 to see what exactly the code does.
I would prefer to see a code snippet from the failure immediately in the test results.
For instance

With this knowledge, I can write my tests much wiser. I would use meaningful variable names, to provide a context about the failure.
I often find myself in a situation, when I cannot express my intention with a pester test.
By express I mean: person who see failed test results should understand what's the matter of failure with the least possible actions.
For example, let's take some binary condition.
Let's say these are my functions:
I want to express:
Get-SmartFooshould work faster thenGet-DumbFoo(which is currently not true).Here is what I can write:
Imagine, you didn't touch test code for a while. Probably, you will go to the source and find the line 20 to see what exactly the code does.
I would prefer to see a code snippet from the failure immediately in the test results.
For instance
With this knowledge, I can write my tests much wiser. I would use meaningful variable names, to provide a context about the failure.