Open hob opened 12 years ago
Hob, I've pushed some changes that may help. Care you pull from master and see if this issue pops up?
Actually, I can't compile now... I was leveraging Mockolatier.prepareClassRecipies() which no longer seems to be available.
Mockolatier.prepareClassRecipes()
is still available. Got an error or example?
Here's the method that calls it:
public static function prepareMockableSystemClasses(data:MockolateRunnerData, parentToken:AsyncTestToken):void { _parentToken = parentToken; if(mockableSystemClassesPrepared) { injectMocks(null); }else{ var preparer:IEventDispatcher = data.mockolatier.prepareClassRecipes(getSystemClassRecipies()); preparer.addEventListener(Event.COMPLETE, injectMocks); mockableSystemClassesPrepared = true; } }
The compile error is:
Description Resource Path Location Type 1195: Attempted access of inaccessible method prepareClassRecipes through a reference with static type mockolate.ingredients:Mockolatier. TestUtil.as /trunk/[source path] test-flex/com/workday/ui/flex line 103 Flex Problem
Looks like it's under a new namespace. I'll try just switching to prepare() and see how that goes.
Ok... I refactored our code to use prepare() and things are compiling now. I've also been able to get the suite to run to completion, but not every time. Now, however, I don't see the null pointer as before. Instead the suite just stalls.
Can you elaborate on your test setup? You appear to not be using the MockolateRule and using the runner statements in some other setup. I haven't considered that the runner statements may be used directly as part of the public API.
What sort of classes are you mocking? Lots of UIComponents and other Flex / Flash classes or mostly application code like services and models?
We use MockolateRunner directly for some tests, but there are other cases where we use a new runner that I've created. That runner sub-classes MockolateRunner. Where it's declared (using RunWith()) I automatically inject mock versions of some of our core system classes (application event bus, service locator, event queue, etc..) before each test and automatically verify all of those system mocks after each test. Those classes are all declared by interface on our parsley context so none of them are terribly large.
What this buys us is greatly improved test isolation; especially where the application event bus is concerned. With this implementation, one does not have to worry about some system event dispatching from a test subject and triggering a large code path. We can simply declare an expectation on that mock application event bus in our test code without having to explicitly declare it in our tests (since its setup by our new runner) and it will get automatically verified after the test is complete.
btw... If you'd like to see any of this in action and step thru the code, I'd be happy to setup a screen share. You have my email.
Is there any update on this issue? I have a project where we are using Mockolate for and are randomly seeing this error as well. So far, we have been unable to pinpoint where/why it is happening, but its proving problematic for our continuous integration builds.
Submitted pull request with fix. https://github.com/drewbourne/mockolate/pull/56
Submitted another pull request after realizing a problem still remained.
Well done. I'll get updated & kick off a few runs of the suite. Thanks!
Nice work! :)
Drew, this is the error I emailed you about. Creating this so that you can track it publicly. The error in question seems to occur randomly and the test suite is otherwise passing: