On Nov 20, 8:30 am, Ian MacLennan <
ian.maclen...@joomla.org> wrote:
> I had process isolation working fine for the cases where it was required
> using @runInSeparateProcess. The way I had this implemented was
> specifically for the where we load mocks, so that we could run tests that
> need mocks in a separate process and not have the mock classes interfere
> with the real classes.
Yes, but I ran into difficulty with it while testing the changes I was
making to move the JUtility code. Specifically, the problem was that
JSessionTest loaded session.php, and after that was loaded, I could no
longer use getMock in JUtilityTest to create a mock JSession object
with a method overriding the static method I had added to JSession.
(If the method were not declared static, the test and the mock object
would work fine. Static, and the method in JSession would supplant the
mock method.) The tests would pass only so long as no other test in
the entire suite loaded session.php, but as soon as any test loaded
that file, the tests failed, despite the fact that the tests
themselves were not changing, nor were the data the tests were being
performed upon.
This happened despite @runInSeparateProcesses, and when it happened it
became apparent to me that I was never really achieving isolation. At
best I was getting a "sort of" isolation which I couldn't trust
because I had an example right in front of me of one test corrupting
the results of another, supposedly isolated, test.
> I have attached the wiki source for the only docs I could really find that
> we had. We had done something based on patError at one point. We don't
> have the patError library anymore, but I don't know how closely we used the
> concepts. The forum thread is athttp://
forum.joomla.org/viewtopic.php?f=304&t=24910. The mentioned wiki
> source is attached to this email.
I'll check that over. I've wondered about maybe some pages in the wiki
to capture live for all of us the wisdom we each glean from our
trials. Testing tips that we've found useful or things we've found
especially problematic. But maybe that sort of thing is best left for
this medium instead, and only at the end gathered up and made sense of
for posterity.
I've committed the new version of JSimpleXMLTest to the unittest tree.
The new touches are above the setup method. In a nutshell, setup saves
the current state of the error handler, sets it to callback for
everything and points it at the callback method provided by
JSimpleXMLTest to record the error message, initializes the error
recording location, then instantiates the class and begins testing.
Teardown then restores the error handlers on the way out, back to what
they were before the test began.
Whenever you start exploring black boxes like I did, you invariably
come up with some "superstitious" rules, rules that don't really exist
but only appear to be rules because of the way you poked around the
box. I've tried to clean all the superstition out of the test code; if
you find some still there, let me know.
> It seems to me that throwing an error inside JError is in general not the
> best idea. I would be inclined to just die or something if something inside
> JError itself fails, or at least handle it in a way that it won't invoke
> itself (I have a hard time imagining that if JError failed the first time
> through that it would pass the second time through).
It's not so much that it's throwing an error inside JError itself, but
rather that JError is calling a JFactory method as part of its error
handling, which in turn is throwing another error. JError, under the
error handling mode it's been told to follow, then detects that this
latest error has been thrown while handling a previous error, declares
it's in an infinite loop and quits.
While poking around the black box of JError, I found a couple of
options that managed to escape the loop detection, but not the loop,
and it was only this particular callback combination that seemed to
escape the loop as well.
It's always a bit iffy to include the normal code of a system in error
handling, because once an error happens you can't count on the system
being fit to do any processing at all, but I'm going to wait until far
more than the current 10% of the system is under test before I start
doing more than idly speculating about major rework efforts like that.
I want a more accurate picture of where we are before we even think
about changing course.