Open SergeyZalyadeev opened 11 years ago
Nice! Try this: !|script| |show |eval |try { throw "TEST!!!" } catch { $error[0] }|
but this works fine
!|script| |show |eval |1/0|
should this technique "try...catch" be used for any non trivial eval with possible "throw" inside?
You want something like this: !|script| |show |try|throw "TEST!!!"| ?
I've been working on this problem for a while myself, trying to add proper exception handling to PowerSlim to make debugging easier and to ensure that FitNesse doesn't throw an exception even when PowerSlim does.
I have quite a bit of it working now and I'll post what I can later when I have a chance to clean it up and remove some of the customization I don't think others will be interested in. My changes revolve around the following:
__EXCEPTION__
+ additional info when exceptions are encountered, allowing FitNesse to report the problems gracefully__EXCEPTION__:ABORT_SLIM_TEST:
when a throw StopTest:<Additional Info>
' is executed, allowing testing to abort properly and intentionally, per the SlimProtocol spec, and allowing error info to be reported. This is useful so that you can intentionally abort your test when certain critical tests fail, like when you find your web server or database server is down.__EXCEPTION__:ABORT_SLIM_TEST:
error has occurred while processing a prior command.I have it all pretty functional now, but like I said, I have some custom error handling that I need to remove before posting it since it's specific our our testing environment. I need to invest some time in learning GitHub too. :)
ALuckyGuy, that is cool. Looking forward for your commits :)
ALuckyGuy, is there any progress on your improvements in exception handling? It would be great if you commit your changes - I have the same issue with poweshell exceptions..
Thanks for the reminder. I struggled with getting GitHub to work through our proxy at work and then gave up, planning to come back to it later when I had time. Your post prompted me to get back to it.
I'm merging changes now. It's a little more complicated than I hoped because I've made so many changes to slim outside of this - and to a much older release, Rev 42 - that it's proving a little tedious to merge only the changes related to error-handling. In any event I hope to finish today and update my fork.
An update... after merging my changes there are a few of the standard PowerSlim tests that are failing so I'm researching those to see what I've managed to break. As I mentioned, I was working from a much older PowerSlim version that I had customized considerably, so merging just the error handling changes into the latest code line is a bit of a challenge. Hopefully I'll have it done soon.
Looking for a little advice on how to setup exception tests.
I have my changes merged and the exception handling is working. If tests fail due to an exception they get reported as exceptions in FitNesse, and per slim protocol, you can throw a "StopTest" exception and the remainder of the current test table won't execute and FitNesse will halt execution of the tests that follow. Setting up tests that verify this behavior and that return a successful status is diffcult however.
I notice in FitNesse's own test page for slim exception handling they use a page driver fixture which takes a page definition that's defined in the test table, creates it and executes it, and then searches the results for the exception output. Anyone know how to do something similar with our slim server? I can create tests that throw exceptions and demonstrate the desired behavior easily enough, but those exceptions aren't considered a success by FitNesse itself because they are, after all, tests that ended in exceptions.
Hi ALuckyGuy,
I see couple of ways to test this:
Where is your fork/branch? Can you create pull request? Then I would try to write test for this enhancement.
Thanks for those ideas Mike.
Regardling your first suggestion, if I understand correctly I would start up another slim server and then submit my request to it - using the SLIM protocol - and parse the output. Doable, but that seems difficult to get exactly right and even more difficult to maintain. Ironic that you suggested this too because this is one of the tests that fails now with my changes - it returns a true exception on the | show | eval | $stream.Read($data,0,1) | when the read time's out. It should, but now is a little more of a challenge to have it deemed a "right" assertion.
Re: the second, I'm not quite sure how I'd incorporate those into a FitNesse test suite but as it turns out I think I've found a way to do it now anyway.
I can use FitNesse's RESTful services to execute the test page and then interrogate the output. I can probably create the page dynamically too but for now I'm just going to use the restful interface to run the test pages and verify they "fail" with an exception as expected. Hopefully I'll be done by the end of the day and update my fork with the changes.
Great! Thanks a lot!
JUST for the record! So I would not forget it how I would do it :)
Regarding 1) to get the right SLIM string you could sniff SLIM protocol in the Output of the Fitnesse by un-commenting #$VerbosePreference="Continue" in slim.ps1, 12
2) Unit Tests now can be started by running nose
BUT
Agree. Your approach is much better!
Ok, created a pull request with my changes but forgive me if I screwed something up - this was the first time I've used GitHub.
My slim.ps1 file is showing up as a binary file type. GitHub lets you view the file ok but it doesn't show the differences properly. I noticed Notepad++ was reporting the original is encoded as UCS-2 Little Endian and my revised slim.ps1 file was the same. I converted it to UTF8 and uploaded it with the same result. Finally I changed it to ANSI and uploaded it and now at least GitHub no longer seems to identify it as binary. Not sure what I'm doing, clearly. :)
Hi ALuckyGuy,
I think the issue you've got is described here https://help.github.com/articles/dealing-with-line-endings
I want to add .gitattributes to the repo with this setting:
text
This setting tells git to always normalize the files specified.
When committed they are stored with LF, on checkout they are converted to the OS's native line endings.
Then It would be really great if you manage to make Pull Request with the true difference. Now it shows everything has been changed in slim.ps1 file.
Committed .gitattributes
Thanks. I'll see if I can figure out how to re-create my pull request with that setting correct. It won't be until much later today though since GitHub doesn't work through my proxy at work.
You could use CNTLM http://cntlm.sourceforge.net/ for authentication against your corporate proxy, then you set up https_proxy environment variable pointing to cntlm.
and when cloning/pulling/pushing you could use https instead of ssh
git clone https://github.com/ALuckyGuy/PowerSlim.git
Hi @ALuckyGuy ,
We (I and @SergeyZalyadeev ) have fixed the issue with the line endings in your pull request. Now all your changes are in the branch https://github.com/konstantinvlasenko/PowerSlim/tree/ALuckyGuy-master.
@SergeyZalyadeev will review it and comment it there
@ALuckyGuy, for getting your local repo fixed (endings), you can merge your master with ALuckyGuy-master branch from powerslim!
Thank you for your assistance and the info. I really appreciate it, and as you can tell, I really need it too. :)
What are we doing with this issue? Is it fixed already?
the following table crashes PowerSlim
!|script| |show |eval |throw "TEST!!!"|