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

Improved Error Handling (#51) #52

Closed ALuckyGuy closed 10 years ago

ALuckyGuy commented 10 years ago

Modified to detect and report exceptions to FitNesse; added support for tests to abort a test run with the ABORT_SLIM_TEST exception.

ALuckyGuy commented 10 years ago

Good catch.

FYI, Invoke-RestMethod is v3 only and used on the PowerSlim.OriginalMode.SuiteExceptions.ExceptionTestRunner test page. I think I can make it v2 compatible b converting it to use System.Net.WebRequest and accomplish the same purpose. I probably won't have time to do that for a day or two, but I'll see what I can do.

ALuckyGuy commented 10 years ago

I've commited changes to address the v2 compatibility of the tests and the suite abort handling.Not sure if I should do another pull request or not.

konstantinvlasenko commented 10 years ago

warning: Cannot merge binary files: slim.ps1 (HEAD vs. ALuckyGuy-master) Auto-merging slim.ps1 CONFLICT (content): Merge conflict in slim.ps1

strange content inside the file:

########################## ਍⌀ 倀漀眀攀爀匀氀椀洀 ⠀刀攀瘀椀猀椀漀渀 㐀㜀⤀⌀ഀഀ ########################## ਍␀猀氀椀洀瘀攀爀 㴀 ∀匀氀椀洀 ⴀⴀ 嘀 ⸀㌀怀渀∀ഀഀ $slimnull = "000004:null:" ਍⌀␀猀氀椀洀瘀漀椀搀 㴀 ∀⼀开开嘀伀䤀䐀开开⼀∀ഀഀ $slimvoid = "" ਍␀猀氀椀洀攀砀挀攀瀀琀椀漀渀 㴀 ∀开开䔀堀䌀䔀倀吀䤀伀一开开㨀∀ഀഀ $slimsymbols = new-Object 'system.collections.generic.dictionary[string,object]' ਍⌀␀猀氀椀洀戀甀昀昀攀爀 㴀 渀攀眀ⴀ漀戀樀攀挀琀 戀礀琀攀嬀崀 ㄀ ㈀㐀  ഀഀ

$slimbuffersize = 0

਍⌀␀嘀攀爀戀漀猀攀倀爀攀昀攀爀攀渀挀攀㴀∀䌀漀渀琀椀渀甀攀∀ഀഀ

਍⌀匀甀瀀瀀漀爀琀 昀漀爀 猀氀漀眀 挀漀渀渀攀挀琀椀漀渀ഀഀ

$ps_stream.ReadTimeout = 10000 #idea is that the client should send data, so the stream is in the read mode. We can wait 10 seconds or more?

਍␀刀䔀儀唀䔀匀吀开刀䔀䄀䐀开吀䤀䴀䔀伀唀吀 㴀 ㄀    ഀഀ $script:SLIM_ABORT_TEST = $false ਍␀猀挀爀椀瀀琀㨀匀䰀䤀䴀开䄀䈀伀刀吀开匀唀䤀吀䔀 㴀 ␀昀愀氀猀攀ഀഀ

ALuckyGuy commented 10 years ago

I don't really understand what happened. If you click View File in GitHub, it shows the text fine. If you have any suggestions please let me know.

NevRA commented 10 years ago

ALuckyGuy plz could you fix file encoding and try to make pull request again?

ALuckyGuy commented 10 years ago

Will do, though I won't be able to do so until later this weekend.

On Thu, May 8, 2014 at 7:36 AM, Roman Abdulmanov notifications@github.comwrote:

ALuckyGuy plz could you fix file encoding and try to make pull request again?

— Reply to this email directly or view it on GitHubhttps://github.com/konstantinvlasenko/PowerSlim/pull/52#issuecomment-42539852 .

ALuckyGuy commented 10 years ago

Ok... I finally sorted out the encoding problem and remerged my changes in with the latest. Sorry it's taken so long.

Besides the error handling changes, also corrected a bug where slim sent the text "buy" to FitNesse instead of "bye" when slim terminates.

konstantinvlasenko commented 10 years ago

Hi ALuckyGuy, Sorry for the late response. I have merged your changes to the test branch. We'll run them in the productions during the next week. Then I'll merge them to the master. Thank you!

ALuckyGuy commented 10 years ago

Note, I've made a minor update to the ExceptionTestRunner test page in my repo. Since this hasn't been merged yet I can't earily create a new, meaningful pull request.

konstantinvlasenko commented 10 years ago

Hi AluckyGuy, So something changed related to how we handle exceptions? Check this test http://localhost/PowerSlim.OriginalMode.SuiteCommon.TestPsobjectInQueryTable It behaves differently before and after your changes. The main problem is that it stops the whole Suite execution http://localhost/PowerSlim.OriginalMode.SuiteCommon.

konstantinvlasenko commented 10 years ago

Merged. Thank you!

ALuckyGuy commented 10 years ago

I'm not seeing a difference with http://localhost/PowerSlim.OriginalMode.SuiteCommon.TestPsobjectInQueryTable or the whole Suite execution. Did you resolve the problem on your own?

konstantinvlasenko commented 10 years ago

Yes. There are were another issue within the test itself (if PS 4.0) https://github.com/konstantinvlasenko/PowerSlim/commit/55a18757ce546aea68c8460e3f8f807b6c43eb25

konstantinvlasenko commented 10 years ago

BTW: I really like the changes from this pull request. Previously a lot of error were hidden while tests execution. So right now you should explicitly specify if error is not a real error :) e.g. In our tests we have step which loads the SharePoint snap-in. Add-PSSnapin Microsoft.SharePoint.PowerShell

You will get SLIM_ABORT_TEST If you run this step for the second time. With your new changes we need to specify -erroraction 'silentlycontinue' Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction 'silentlycontinue'

konstantinvlasenko commented 10 years ago

Idea: Sometimes we are expecting an exception. It would be nice to introduce the exception action (like eval). So we can wright something like this:

|check|exception|throw "Exception Message"|Exception Message|

What do you think?

ALuckyGuy commented 10 years ago

That's an interesting idea - checking for an exception explicitly. I'm not sure if it's really possible given FitNesse's special handling of the "EXCEPTION" result - that produces special behavior within the wiki server.

I struggled with how to successfully create tests for the exception handling myself until I realized I could used PowerShell to invoke the FitNesse tests RESTfully and then search the results. You should look at PowerSlim.OriginalMode.SuiteExceptions.ExceptionTestRunner if you haven't had a chance.

konstantinvlasenko commented 10 years ago

BTW: check this test PowerSlim.OriginalMode.SuiteCommon.TestScenario at the bottom.

konstantinvlasenko commented 10 years ago

I think in case of special action exception we should catch exception and not follow the SLIM protocol. But report an exception metrics back as a result. The simple solution is just sending an exception message as a result.

ALuckyGuy commented 10 years ago

Re: using FitNesse's -c option to execute a test, I was aware of that but I wanted to not only execute it but then parse the results for exception messages, confirm execution of the tests continued when they should, etc. I thought executing the test pages via the RESTful syntax was better in that regard.

Re: having a new exception keyword that suppresses regular exception handling, it would certainly work but the benefit isn't clear to me. Tests using it would confirm that an exception was thrown and that the special, non-standard exception handling worked, but it wouldn't confirm that the regular SLIM protocol exception handling worked. Maybe it would be useful for testing a variety of exception conditions for the SUT though.