konstantinvlasenko / PowerSlim

Fitnesse Slim implementation in PowerShell. PowerSlim makes it possible to use PowerShell in the acceptance testing
powerslim.org
GNU General Public License v3.0
48 stars 21 forks source link

Yellow test if Empty Try/Catch #73

Open konstantinvlasenko opened 9 years ago

konstantinvlasenko commented 9 years ago

https://github.com/konstantinvlasenko/PowerSlim/blob/master/FitNesseRoot/PowerSlim/OriginalMode/SuiteCommon/TestCatchException/content.txt

2xmax commented 9 years ago

Hmm, I tried to use $Lastexitcode and $?. Unfortunately, It does not recognize errors like Get-Service invalidservice. AFAIK, it is very hard or impossible to redirect error stream only to PS variable without temporal file. Maybe you have other ideas?

konstantinvlasenko commented 9 years ago

@2xmax I didn't get how Get-Service invalidservice relates to this issue? I, believe, in you example the exception were handled internally by underlying code of Get-Service. And what you seen in the console output is just the result of Write-Host. I think nothing can be done here. But again, it is not about the issue we are trying to discuss :)

konstantinvlasenko commented 9 years ago

I think the main issue is that we have removed this ELSE https://github.com/konstantinvlasenko/PowerSlim/pull/71/files#diff-3a586a9b299992da7ba63a2496a138f2L312 for non-terminating error. We should just return the error as the result of the script execution. But not as SLIM exception. What do you think?

2xmax commented 9 years ago

The main problem with previous version was concerned with skipping such statements: |eval|$somevar=Get-XXXFeature| where Get-XXXFeature write some very important info in std error (that is actually visible in powershell console). My idea was to highlight such test yellow.

2xmax commented 9 years ago

(if I understood you right, powerslim will not show the error if we just return it as result of script execution)

konstantinvlasenko commented 9 years ago

It will if you will use |check| or |show|

konstantinvlasenko commented 9 years ago

Maybe we should introduce a global setting?! $NonTerminatingIsException = $true In this case we'll use your new approach. What do you think?

2xmax commented 9 years ago

It will if you will use |check| or |show|

I remember several times I received such test reports: |eval|...something..may not broke..| # but it broken for unpredictable moment, and the result of this was very interesting |check|eval|Get-XXXFeature|...| it comes out I created |PS| scenario that executed |show|eval|@script|, then I modified slim.ps1 and got rid of |PS| scenario.

2xmax commented 9 years ago

BTW, not only me used this |PS| scenario:)

konstantinvlasenko commented 9 years ago

So what we are going to do? I don't want to Test-Path before calling Remove-Item.

konstantinvlasenko commented 9 years ago

I think the $NonTerminatingIsException = $true should be enough for your case. You can always set it to TRUE. But by default it should be FALSE.

2xmax commented 9 years ago

NonTerminatingIsException flag is ok for me. I agree with you, It can be painful if there are already a lot if rmdir and remove-items in suite.

konstantinvlasenko commented 9 years ago

remove-items is just one example :) It can be Remove-SPWeb or DELETE method for any REST API for non-existing object. Basically we are talking about any cleanup operation. I don't want to check the existence of something before removing it. Can you make this change?

2xmax commented 9 years ago

ok, will do