flex mock testing frameworks: comparative analysis

19
Mocking in ActionScript 3.0: Comparative Analysis of various mocking frameworks

Upload: nitin-khattar

Post on 10-May-2015

2.114 views

Category:

Technology


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Flex Mock Testing Frameworks: Comparative Analysis

Mocking in ActionScript 3.0: Comparative Analysis of various

mocking frameworks

Page 2: Flex Mock Testing Frameworks: Comparative Analysis

Basic HighlightsImportance of Mocking in Unit TestingHow to Mock?Exploring various mocking frameworksHands On some frameworksQ & A

Page 3: Flex Mock Testing Frameworks: Comparative Analysis

What is Mocking?

What is Mock Object?

Page 4: Flex Mock Testing Frameworks: Comparative Analysis

mock objects are simulated objects that mimic the

behavior of complex, real objects in controlled ways

Page 5: Flex Mock Testing Frameworks: Comparative Analysis

Why to Mock?

When to Mock?

Mock == Actual Object?

Page 6: Flex Mock Testing Frameworks: Comparative Analysis

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).

Page 7: Flex Mock Testing Frameworks: Comparative Analysis

How to mock?

Page 8: Flex Mock Testing Frameworks: Comparative Analysis

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;

Page 9: Flex Mock Testing Frameworks: Comparative Analysis

Traditional Way

Vs

Mocking Frameworks

Page 10: Flex Mock Testing Frameworks: Comparative Analysis

Traditional Way

Page 11: Flex Mock Testing Frameworks: Comparative Analysis

Evolution of Mocking Frameworks

Mock4AS

MockAS3

Mockolate

Page 12: Flex Mock Testing Frameworks: Comparative Analysis

Mock4ASRecord, Expect & VerifyAdded Mock into Traditional ApproachMore of Traditional touch and posses similar

issuesLess mature

Page 13: Flex Mock Testing Frameworks: Comparative Analysis

MockAS3Expectation BasedSimilar to Mock4AS in approachEnhanced Setting Expectations

* Receive Count , Property, Ordering Expectations, Calling Functions

Posses problems similar as in Traditional approach

Page 14: Flex Mock Testing Frameworks: Comparative Analysis

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.

Page 15: Flex Mock Testing Frameworks: Comparative Analysis

Kick started the concept of proxy mock objects

Purely Record-Replay BasedTotally bypassed the Traditional ApproachDifficult & complex to implementEnhanced & Advance Features:

Mock RepositoryMulti-Platform support (Flexunit, Asunit, Fluint..)Argument ConstraintsStub | Dynamic | Strict MocksEvent Stubbing …

Page 16: Flex Mock Testing Frameworks: Comparative Analysis

Purely Expectation BasedBased on Mockito for JavaEasy to learn & integrateMatcher, Hamcrest API integratedEmploys the concept of Rule & Runner in

FlexunitNot much advanced & mature features like

ASMock

Page 17: Flex Mock Testing Frameworks: Comparative Analysis

MockolateInclude Good aspects of ASMock & Mockito Expectation & Record-Replay basedNice | Strict | Partial MocksMocking & StubbingTest SpiesDecorators like EventDispatcher, HttpServiceCannot mock classes in default package

Page 18: Flex Mock Testing Frameworks: Comparative Analysis

What Suites You??

Page 19: Flex Mock Testing Frameworks: Comparative Analysis

Questions??