Mocking in ActionScript 3.0:  Comparative Analysis of various mocking frameworks
Basic Highlights <ul><li>Importance of Mocking in Unit Testing </li></ul><ul><li>How to Mock? </li></ul><ul><li>Exploring ...
What is Mocking? What is Mock Object?
mock objects  are simulated objects that mimic the behavior of complex, real objects in controlled ways
Why to Mock? When to Mock? Mock == Actual Object?
If an object has any of the following characteristics, it may be useful to use a mock object in its place: - supplies  non...
How to mock?
Example:  The Greeting component says Hello in any language. Greeting uses a Translator component to translate “Hello” fro...
Traditional Way Vs Mocking Frameworks
Traditional Way
Evolution of Mocking Frameworks Mock4AS MockAS3 Mockolate
Mock4AS <ul><li>Record, Expect & Verify </li></ul><ul><li>Added Mock into Traditional Approach </li></ul><ul><li>More of T...
MockAS3 <ul><li>Expectation Based </li></ul><ul><li>Similar to Mock4AS in approach </li></ul><ul><li>Enhanced Setting Expe...
FlexUnit: Runners & Rules Runners are classes that implement IRunner, and have the capability to run specific types of sui...
<ul><li>Kick started the concept of proxy mock objects </li></ul><ul><li>Purely Record-Replay Based </li></ul><ul><li>Tota...
<ul><li>Purely Expectation Based </li></ul><ul><li>Based on Mockito for Java </li></ul><ul><li>Easy to learn & integrate <...
Mockolate <ul><li>Include Good aspects of ASMock & Mockito  </li></ul><ul><li>Expectation & Record-Replay based </li></ul>...
What Suites You??
Questions??
Upcoming SlideShare
Loading in …5
×

Flex Mock Testing Frameworks: Comparative Analysis

3,101 views

Published on

The presentation gives a comparative analysis of various mocking frameworks available to help writing unit tests in Actionscript/Flex

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,101
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Flex Mock Testing Frameworks: Comparative Analysis

  1. 1. Mocking in ActionScript 3.0: Comparative Analysis of various mocking frameworks
  2. 2. Basic Highlights <ul><li>Importance of Mocking in Unit Testing </li></ul><ul><li>How to Mock? </li></ul><ul><li>Exploring various mocking frameworks </li></ul><ul><li>Hands On some frameworks </li></ul><ul><li>Q & A </li></ul>
  3. 3. What is Mocking? What is Mock Object?
  4. 4. mock objects  are simulated objects that mimic the behavior of complex, real objects in controlled ways
  5. 5. Why to Mock? When to Mock? Mock == Actual Object?
  6. 6. If an object has any of the following characteristics, it may be useful to use a mock object in its place: - supplies  non-deterministic results (e.g. the current time or the current temperature); - has states that are difficult to create or reproduce (e.g. a network error ); - is slow (e.g. a complete database, which would have to be initialized before the test); - does not yet exist or may change behavior; - would have to include information and methods exclusively for testing purposes (and not for its actual task).
  7. 7. How to mock?
  8. 8. Example: The Greeting component says Hello in any language. Greeting uses a Translator component to translate “Hello” from English to the selected language. ITranslator is an interface containing the translate method – parameters from, to and word, which returns the translated word;
  9. 9. Traditional Way Vs Mocking Frameworks
  10. 10. Traditional Way
  11. 11. Evolution of Mocking Frameworks Mock4AS MockAS3 Mockolate
  12. 12. Mock4AS <ul><li>Record, Expect & Verify </li></ul><ul><li>Added Mock into Traditional Approach </li></ul><ul><li>More of Traditional touch and posses similar issues </li></ul><ul><li>Less mature </li></ul>
  13. 13. MockAS3 <ul><li>Expectation Based </li></ul><ul><li>Similar to Mock4AS in approach </li></ul><ul><li>Enhanced Setting Expectations </li></ul><ul><li>* Receive Count , Property, Ordering Expectations, Calling Functions </li></ul><ul><li>Posses problems similar as in Traditional approach </li></ul>
  14. 14. FlexUnit: Runners & Rules Runners are classes that implement IRunner, and have the capability to run specific types of suites, tests, or methods. Rules are an advanced concept whose basic functionality is similar to the [Before] and [After] concepts, allowing for reusable, dynamic classes that will execute functionality before and after each test.
  15. 15. <ul><li>Kick started the concept of proxy mock objects </li></ul><ul><li>Purely Record-Replay Based </li></ul><ul><li>Totally bypassed the Traditional Approach </li></ul><ul><li>Difficult & complex to implement </li></ul><ul><li>Enhanced & Advance Features: </li></ul><ul><ul><li>Mock Repository </li></ul></ul><ul><ul><li>Multi-Platform support (Flexunit, Asunit, Fluint..) </li></ul></ul><ul><ul><li>Argument Constraints </li></ul></ul><ul><ul><li>Stub | Dynamic | Strict Mocks </li></ul></ul><ul><ul><li>Event Stubbing … </li></ul></ul>
  16. 16. <ul><li>Purely Expectation Based </li></ul><ul><li>Based on Mockito for Java </li></ul><ul><li>Easy to learn & integrate </li></ul><ul><li>Matcher, Hamcrest API integrated </li></ul><ul><li>Employs the concept of Rule & Runner in Flexunit </li></ul><ul><li>Not much advanced & mature features like ASMock </li></ul>
  17. 17. Mockolate <ul><li>Include Good aspects of ASMock & Mockito </li></ul><ul><li>Expectation & Record-Replay based </li></ul><ul><li>Nice | Strict | Partial Mocks </li></ul><ul><li>Mocking & Stubbing </li></ul><ul><li>Test Spies </li></ul><ul><li>Decorators like EventDispatcher, HttpService </li></ul><ul><li>Cannot mock classes in default package </li></ul>
  18. 18. What Suites You??
  19. 19. Questions??

×