You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mscharp <mi...@fmr.com> on 2014/05/14 19:01:12 UTC

promises-as3, TestingPromise, and Mockolate

I've recently started using the promises-as3 library
(https://github.com/CodeCatalyst/promise-as3) for my  (possibly)
asynchronous calls.  After a slight learning curve, I've got it working in
my code and it's been fantastic to use.  No more event/commands/callbacks!

After I got everything working, I started writing my unit tests.  FML! Unit
testing methods that use/return promises has been a pain in the ass to say
the least.  Has anyone used the promises-as3 library and had good success
writing unit tests for them?  Luckily I found the TestingPromise library
(https://github.com/Hyzhak/testing-promise-as3) but it has its own
limitations unfortunately, such as nesting calls.

Lastly, when using mockolate and [Mock]ing a class that has methods with a
Promise return type, even though the method has been mocked, it is executing
the real function... Has anyone seen this issue?

Anyway, hoping there are folks out there that have had some success unit
testing methods using promises.  Any insights?

Thanks!



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/promises-as3-TestingPromise-and-Mockolate-tp6426.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: promises-as3, TestingPromise, and Mockolate

Posted by mscharp <mi...@fmr.com>.
Heh, unfortunately throwing in the towel is not an option.  I'm finding ways
to test what I need to, even if it requires modifying code to make it more
easily tested.

The only way (I found) to get around the issue you mentioned was to use the
testing-promises-as3 library I mentioned in the first post.  The test has to
be asynchronous, and the limitation is that it seems you can only test a
single promise chain. This was problematic for me because I wanted to test a
cache/refresh feature of the code, but calling specific method and using the
TestingPromise framework resulted in errors that I have been unable to
resolve.  

Once I get some more of tests written, I'll try to post on here a few
examples in case others venture down the promises path and need some help.

Michael



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/promises-as3-TestingPromise-and-Mockolate-tp6426p6437.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: promises-as3, TestingPromise, and Mockolate

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

I had a bit of trouble trying to test promises in the past as well.

This bug or rather intended feature caused a lot of grief:
https://github.com/CodeCatalyst/promise-as3/issues/28

Are you calling done?

Thanks,
Justin