SlideShare a Scribd company logo
1 of 32
assertYourself()
Breaking All of the Theories and Assumptions of
               Unit Testing in Flex




         Michael Labriola
           Jeff Tapper
               Digital Primates
Who are you?
Michael Labriola
Senior Consultant at Digital Primates


Jeff Tapper
Senior Consultant at Digital Primates

             Flex Geeks - Team Mentors
                Fans of Working Code
What is this session about?

Automated Testing.

However, because we expect a mix of people at
  different levels of commitment to the idea of
  testing we need to cover a few major areas
Topics I
Why Test Code – If you don’t know why this
 matters, you aren’t really going to care about
 the rest

Writing Testable Code – 99% of writing good tests
 is good architecture.
Topics II
Writing Unit Tests – How do you go about writing
 and executing unit tests

Introducing Theories and DataPoints – verifying
  functionality over a larger set of values

Writing Integration Tests – Integrate your units
 and let the real fun begin
The sad facts
Software Errors cost a lot of money and time
• A 2002 NIST study found that software errors cost
  the US economy .6% of the US GDP yearly[1]
• That sets the net loss today at about 79.8 billion
  dollars a year

Who pays that?
• Half of that is absorbed by people who buy software
• The other half is absorbed by people who create
  software
More sad facts
Software errors are also the majority of development
  cost
• The same study found that, on average, 80% of
  development costs are spent on identifying and
  correcting defects
• So, the majority of the development time is spent
  creating software that still causes almost 80 billion in
  issues
The important part
The cost of fixing these errors is correlated to when
  they are found[2]
• A requirements error found after release can cost 10
  – 100 times as much to fix as during the
  requirements gathering phase
• An architecture error found after release can cost 25-
  100 times as much to fix this late in the process
• The point.. Finding issues early == good. Finding
  issues late == bad.
Why Test Automatically?
It allows us to test much more often than we could do so
   manually

• There are only so many hours in the day.
• Code that hasn’t been exercised in a while is always
  suspect
• When you’re tired, do you test as effectively?
  Computers tend not to get tired.
Why Test Automatically?
It is cheaper than hiring teams of QA folks (or spending
    your time) to execute manual tests continually

• Automated tests cost money to write and money to
  maintain, however, once a test is written, you can run
  it forever for a near zero cost.
• Manual testing which costs little in the beginning, but
  re-occurs every time you wish to test
Why Test Automatically?
It reduces the time to find and quash bugs

• Automated tests can run continuously
   – When you create a new bug, it is likely to be caught in a very
     short period of time.
   – When you have context, you fix issues more quickly
   – The longer you wait to resolve a bug, the more likely it is that
     more code will need to be touched
Why Test Automatically?
It allows you to change and rewrite code without fear of
   breaking something else

• How do you know that a seemingly innocuous change in
  a piece of code today doesn’t have repercussions in
  some rarely run portion of the project?
• With sufficient tests you can change code and sleep
  better
Why Test Automatically?
It increases the quality of the software you write

• If you write tests for your code, you tend to ensure the
  architecture can support testing… generally that also
  means you architected it at least mostly okay
• Code with a lot of automated tests will have been
  tested thousands of times in the course of development
• Bugs will still exist, but they are less likely to be
  fundamental and immediately noticeable
Last but not..
We appear to be more effective developers

When you deliver solid code that works the first time you
  are perceived as effective
Types of Testing
Unit
• Taking the smallest piece of code, isolated from any
  other factors and determining if it behaves as you
  expect.

Integration
• Assembling already tested units and ensuring the
   behavior and interaction between those units are
   correct.
More Testing
Functional
• Translating functional requirements of an application
  into test cases, which can be run to ensure
  requirements have been met.

A million or so more varieties
• Performance, acceptance, etc., etc.
Coding for Testing
This is most of the battle. If you write code that follows these
  general architectural principals, testing it is viable and less
  stressful.

If you don’t, well, good luck
Coding for Testing
Separate construction and application logic
protected function doSomeStuffWithSomeClass():void {
  //does stuff
  var x:SomeClass = new SomeClass();
  //does more stuff
}

protected function doSomeStuffWithSomeClass(
  someClass:SomeClass ):void {
  //does stuff
  //does more stuff
}
Coding for Testing
Use interfaces!

protected function positionThing(
  component:UIComponent ):void {
}

protected function positionThing(
  component:IUIComponent ):void {
}
Coding for Testing
Don’t reach through another object for its
  properties

protected function doThing():void {
  someObject.someProperty.someObj.method();
}
Coding for Testing
Avoid global state in things you wish to test

protected function doThing():void {
  addValue( mySingleton.getInstance().firstVal );
}
Coding for Testing
New objects made through composition are easier
  than those created through inheritance

Composed objects can be substituted with
  different composition at runtime. You can’t
  change your parents.
Coding for Testing
Separate concerns

Classes which need the word *and* to explain
  them are hard to test

public function
  createObjectsAndPositionThem():void;
Writing Unit Tests
What methods/classes should you write unit tests
 for?
• Anything that could possibly break
• Any method that can’t be verified by simple inspection


When writing tests you are either checking a
 return value or looking for a side-effects
 created by a method.
   – If a method doesn’t do either, what in the world does it do?
Fakes, Stubs and Mocks
A unit test needs to test an isolated unit. Fakes,
  stubs and mocks are techniques for isolating
  the unit under test.

For our purposes Fake object, stub and mock
  objects are objects that are instantiated
  instead of real implementations when an object
  under test expects to interact with other
  objects.
Fakes, Stubs and Mocks
Fakes and stubs are generally dumb objects which
  may respond or fulfill the requirement but do
  little else.

Mock objects allow you to set expectations of
 how they will be ‘touched’ during the test and
 then make assertions based on those
 expectations
Theories and DataPoints
What happens when we might need to write a
 test over a potentially infinite dataset of
 possibilities?

What if you need to test objects in multiple
 states with different data points?
Integration Tests
You have diligently tested all of the units you
  could; now how do you test them together?

Integration tests are less likely to use mocks, and
  more likely to test all real units involved
Integration Tests
In the simplest case, things look just like unit
  tests, call some methods, do assertions.

In more complicated situations, you may need to
  deal with asynchronous aspects

In even more complicated situations, you may
  need to do a fair amount of setup to get to the
  point needing a test
Q&A
Seriously? You must have some questions by now?
Play and Vote
Take a look at the latest beta bits:

http://opensource.adobe.com/wiki/display/flexunit/FlexUnit


If you think the new features are important to your
   workflow, let Adobe know:

https://bugs.adobe.com/jira/browse/FB-18873
Resources
Flex Unit 4!
http://opensource.adobe.com/wiki/display/flexunit/FlexUnit


Labriola’s Blog
http://blogs.digitalprimates.net/codeSlinger/


Tapper’s Blog
http://blogs.digitalprimates.net/jefftapper/


Follow us on twitter
mlabriola and jefftapper

More Related Content

What's hot

Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOSPablo Villar
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In ActionJon Kruger
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)nedirtv
 
Test driven-development
Test driven-developmentTest driven-development
Test driven-developmentDavid Paluy
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven DevelopmentPablo Villar
 
Agile Test Driven Development
Agile Test Driven DevelopmentAgile Test Driven Development
Agile Test Driven DevelopmentViraf Karai
 
Common Challenges & Best Practices for TDD on iOS
Common Challenges & Best Practices for TDD on iOSCommon Challenges & Best Practices for TDD on iOS
Common Challenges & Best Practices for TDD on iOSDerek Lee Boire
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) CodeOps Technologies LLP
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven DevelopmentFerdous Mahmud Shaon
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)Brian Rasmussen
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
The Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinThe Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinQA or the Highway
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easierChristian Hujer
 
Test Driven Development (TDD) & Continuous Integration (CI)
Test Driven Development (TDD) & Continuous Integration (CI)Test Driven Development (TDD) & Continuous Integration (CI)
Test Driven Development (TDD) & Continuous Integration (CI)Fatkul Amri
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven developmenttoteb5
 

What's hot (20)

TDD Basics with Angular.js and Jasmine
TDD Basics with Angular.js and JasmineTDD Basics with Angular.js and Jasmine
TDD Basics with Angular.js and Jasmine
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)
 
Test driven-development
Test driven-developmentTest driven-development
Test driven-development
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
 
Automation and Technical Debt
Automation and Technical DebtAutomation and Technical Debt
Automation and Technical Debt
 
Agile Test Driven Development
Agile Test Driven DevelopmentAgile Test Driven Development
Agile Test Driven Development
 
Common Challenges & Best Practices for TDD on iOS
Common Challenges & Best Practices for TDD on iOSCommon Challenges & Best Practices for TDD on iOS
Common Challenges & Best Practices for TDD on iOS
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD)
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
The Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinThe Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt Eakin
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
 
Test Driven Development (TDD) & Continuous Integration (CI)
Test Driven Development (TDD) & Continuous Integration (CI)Test Driven Development (TDD) & Continuous Integration (CI)
Test Driven Development (TDD) & Continuous Integration (CI)
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven development
 

Viewers also liked

Automatisation des tests
Automatisation des testsAutomatisation des tests
Automatisation des testsZhu Wei QI
 
Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...
Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...
Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...AQT-presentations
 
[PFE] Master en ingénierie du logiciel
[PFE] Master en ingénierie du logiciel[PFE] Master en ingénierie du logiciel
[PFE] Master en ingénierie du logicielUSTHB & DELTALOG
 
Test de logiciels
Test de logiciels Test de logiciels
Test de logiciels Bilel Abed
 
Stratégie de tests type
Stratégie de tests typeStratégie de tests type
Stratégie de tests typemadspock
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Zohirul Alam Tiemoon
 
Introduction to Acceptance Test Driven Development
Introduction to Acceptance Test Driven DevelopmentIntroduction to Acceptance Test Driven Development
Introduction to Acceptance Test Driven DevelopmentElisabeth Hendrickson
 
Intro sur les tests unitaires
Intro sur les tests unitairesIntro sur les tests unitaires
Intro sur les tests unitairesPHPPRO
 
Outils de tests open-source
Outils de tests open-sourceOutils de tests open-source
Outils de tests open-sourceGilles Mantel
 

Viewers also liked (14)

Les tests en PHP
Les tests en PHPLes tests en PHP
Les tests en PHP
 
Automatisation des tests
Automatisation des testsAutomatisation des tests
Automatisation des tests
 
Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...
Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...
Les outils d’automatisation de tests (scripting) : Adoption et enjeux (comple...
 
[PFE] Master en ingénierie du logiciel
[PFE] Master en ingénierie du logiciel[PFE] Master en ingénierie du logiciel
[PFE] Master en ingénierie du logiciel
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Test de logiciels
Test de logiciels Test de logiciels
Test de logiciels
 
Stratégie de tests type
Stratégie de tests typeStratégie de tests type
Stratégie de tests type
 
Génie Logiciel : les tests
Génie Logiciel : les testsGénie Logiciel : les tests
Génie Logiciel : les tests
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
 
Introduction to Acceptance Test Driven Development
Introduction to Acceptance Test Driven DevelopmentIntroduction to Acceptance Test Driven Development
Introduction to Acceptance Test Driven Development
 
Intro sur les tests unitaires
Intro sur les tests unitairesIntro sur les tests unitaires
Intro sur les tests unitaires
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 
Outils de tests open-source
Outils de tests open-sourceOutils de tests open-source
Outils de tests open-source
 

Similar to assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex

Unit testing
Unit testingUnit testing
Unit testingPiXeL16
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-TestingMary Clemons
 
Test driven development
Test driven developmentTest driven development
Test driven developmentnamkha87
 
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Applitools
 
SELJE_Database_Unit_Testing.pdf
SELJE_Database_Unit_Testing.pdfSELJE_Database_Unit_Testing.pdf
SELJE_Database_Unit_Testing.pdfEric Selje
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testingmarkstory
 
Making the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To TestingMaking the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To TestingCameron Presley
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Abdelkrim Boujraf
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroPaul Boos
 
Introduction to test programming
Introduction to test programmingIntroduction to test programming
Introduction to test programmingopenfinanceDev
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 

Similar to assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex (20)

Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit testing
Unit testingUnit testing
Unit testing
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
 
Automated tests
Automated testsAutomated tests
Automated tests
 
SELJE_Database_Unit_Testing.pdf
SELJE_Database_Unit_Testing.pdfSELJE_Database_Unit_Testing.pdf
SELJE_Database_Unit_Testing.pdf
 
Unit testing - An introduction
Unit testing - An introductionUnit testing - An introduction
Unit testing - An introduction
 
AAA Automated Testing
AAA Automated TestingAAA Automated Testing
AAA Automated Testing
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testing
 
Making the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To TestingMaking the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To Testing
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for Distro
 
Introduction to test programming
Introduction to test programmingIntroduction to test programming
Introduction to test programming
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 

More from michael.labriola

Optimizing Browser Rendering
Optimizing Browser RenderingOptimizing Browser Rendering
Optimizing Browser Renderingmichael.labriola
 
Randori design goals and justification
Randori design goals and justificationRandori design goals and justification
Randori design goals and justificationmichael.labriola
 
Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehosemichael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audiencemichael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audiencemichael.labriola
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributorsmichael.labriola
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy michael.labriola
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Developmentmichael.labriola
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Watersmichael.labriola
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructuremichael.labriola
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Componentsmichael.labriola
 

More from michael.labriola (19)

Optimizing Browser Rendering
Optimizing Browser RenderingOptimizing Browser Rendering
Optimizing Browser Rendering
 
Randori design goals and justification
Randori design goals and justificationRandori design goals and justification
Randori design goals and justification
 
L2624 labriola
L2624 labriolaL2624 labriola
L2624 labriola
 
Talking trash
Talking trashTalking trash
Talking trash
 
Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehose
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributors
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy
 
Apocalypse Soon
Apocalypse SoonApocalypse Soon
Apocalypse Soon
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Development
 
Any Which Array But Loose
Any Which Array But LooseAny Which Array But Loose
Any Which Array But Loose
 
Air Drag And Drop
Air Drag And DropAir Drag And Drop
Air Drag And Drop
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructure
 
Blaze Ds Slides
Blaze Ds SlidesBlaze Ds Slides
Blaze Ds Slides
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components
 
Dense And Hot 360 Flex
Dense And Hot 360 FlexDense And Hot 360 Flex
Dense And Hot 360 Flex
 
Dense And Hot Web Du
Dense And Hot  Web DuDense And Hot  Web Du
Dense And Hot Web Du
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex

  • 1. assertYourself() Breaking All of the Theories and Assumptions of Unit Testing in Flex Michael Labriola Jeff Tapper Digital Primates
  • 2. Who are you? Michael Labriola Senior Consultant at Digital Primates Jeff Tapper Senior Consultant at Digital Primates Flex Geeks - Team Mentors Fans of Working Code
  • 3. What is this session about? Automated Testing. However, because we expect a mix of people at different levels of commitment to the idea of testing we need to cover a few major areas
  • 4. Topics I Why Test Code – If you don’t know why this matters, you aren’t really going to care about the rest Writing Testable Code – 99% of writing good tests is good architecture.
  • 5. Topics II Writing Unit Tests – How do you go about writing and executing unit tests Introducing Theories and DataPoints – verifying functionality over a larger set of values Writing Integration Tests – Integrate your units and let the real fun begin
  • 6. The sad facts Software Errors cost a lot of money and time • A 2002 NIST study found that software errors cost the US economy .6% of the US GDP yearly[1] • That sets the net loss today at about 79.8 billion dollars a year Who pays that? • Half of that is absorbed by people who buy software • The other half is absorbed by people who create software
  • 7. More sad facts Software errors are also the majority of development cost • The same study found that, on average, 80% of development costs are spent on identifying and correcting defects • So, the majority of the development time is spent creating software that still causes almost 80 billion in issues
  • 8. The important part The cost of fixing these errors is correlated to when they are found[2] • A requirements error found after release can cost 10 – 100 times as much to fix as during the requirements gathering phase • An architecture error found after release can cost 25- 100 times as much to fix this late in the process • The point.. Finding issues early == good. Finding issues late == bad.
  • 9. Why Test Automatically? It allows us to test much more often than we could do so manually • There are only so many hours in the day. • Code that hasn’t been exercised in a while is always suspect • When you’re tired, do you test as effectively? Computers tend not to get tired.
  • 10. Why Test Automatically? It is cheaper than hiring teams of QA folks (or spending your time) to execute manual tests continually • Automated tests cost money to write and money to maintain, however, once a test is written, you can run it forever for a near zero cost. • Manual testing which costs little in the beginning, but re-occurs every time you wish to test
  • 11. Why Test Automatically? It reduces the time to find and quash bugs • Automated tests can run continuously – When you create a new bug, it is likely to be caught in a very short period of time. – When you have context, you fix issues more quickly – The longer you wait to resolve a bug, the more likely it is that more code will need to be touched
  • 12. Why Test Automatically? It allows you to change and rewrite code without fear of breaking something else • How do you know that a seemingly innocuous change in a piece of code today doesn’t have repercussions in some rarely run portion of the project? • With sufficient tests you can change code and sleep better
  • 13. Why Test Automatically? It increases the quality of the software you write • If you write tests for your code, you tend to ensure the architecture can support testing… generally that also means you architected it at least mostly okay • Code with a lot of automated tests will have been tested thousands of times in the course of development • Bugs will still exist, but they are less likely to be fundamental and immediately noticeable
  • 14. Last but not.. We appear to be more effective developers When you deliver solid code that works the first time you are perceived as effective
  • 15. Types of Testing Unit • Taking the smallest piece of code, isolated from any other factors and determining if it behaves as you expect. Integration • Assembling already tested units and ensuring the behavior and interaction between those units are correct.
  • 16. More Testing Functional • Translating functional requirements of an application into test cases, which can be run to ensure requirements have been met. A million or so more varieties • Performance, acceptance, etc., etc.
  • 17. Coding for Testing This is most of the battle. If you write code that follows these general architectural principals, testing it is viable and less stressful. If you don’t, well, good luck
  • 18. Coding for Testing Separate construction and application logic protected function doSomeStuffWithSomeClass():void { //does stuff var x:SomeClass = new SomeClass(); //does more stuff } protected function doSomeStuffWithSomeClass( someClass:SomeClass ):void { //does stuff //does more stuff }
  • 19. Coding for Testing Use interfaces! protected function positionThing( component:UIComponent ):void { } protected function positionThing( component:IUIComponent ):void { }
  • 20. Coding for Testing Don’t reach through another object for its properties protected function doThing():void { someObject.someProperty.someObj.method(); }
  • 21. Coding for Testing Avoid global state in things you wish to test protected function doThing():void { addValue( mySingleton.getInstance().firstVal ); }
  • 22. Coding for Testing New objects made through composition are easier than those created through inheritance Composed objects can be substituted with different composition at runtime. You can’t change your parents.
  • 23. Coding for Testing Separate concerns Classes which need the word *and* to explain them are hard to test public function createObjectsAndPositionThem():void;
  • 24. Writing Unit Tests What methods/classes should you write unit tests for? • Anything that could possibly break • Any method that can’t be verified by simple inspection When writing tests you are either checking a return value or looking for a side-effects created by a method. – If a method doesn’t do either, what in the world does it do?
  • 25. Fakes, Stubs and Mocks A unit test needs to test an isolated unit. Fakes, stubs and mocks are techniques for isolating the unit under test. For our purposes Fake object, stub and mock objects are objects that are instantiated instead of real implementations when an object under test expects to interact with other objects.
  • 26. Fakes, Stubs and Mocks Fakes and stubs are generally dumb objects which may respond or fulfill the requirement but do little else. Mock objects allow you to set expectations of how they will be ‘touched’ during the test and then make assertions based on those expectations
  • 27. Theories and DataPoints What happens when we might need to write a test over a potentially infinite dataset of possibilities? What if you need to test objects in multiple states with different data points?
  • 28. Integration Tests You have diligently tested all of the units you could; now how do you test them together? Integration tests are less likely to use mocks, and more likely to test all real units involved
  • 29. Integration Tests In the simplest case, things look just like unit tests, call some methods, do assertions. In more complicated situations, you may need to deal with asynchronous aspects In even more complicated situations, you may need to do a fair amount of setup to get to the point needing a test
  • 30. Q&A Seriously? You must have some questions by now?
  • 31. Play and Vote Take a look at the latest beta bits: http://opensource.adobe.com/wiki/display/flexunit/FlexUnit If you think the new features are important to your workflow, let Adobe know: https://bugs.adobe.com/jira/browse/FB-18873
  • 32. Resources Flex Unit 4! http://opensource.adobe.com/wiki/display/flexunit/FlexUnit Labriola’s Blog http://blogs.digitalprimates.net/codeSlinger/ Tapper’s Blog http://blogs.digitalprimates.net/jefftapper/ Follow us on twitter mlabriola and jefftapper

Editor's Notes

  1. [1] The Economic Impacts of Inadequate Infrastructure for Software Testing - http://www.nist.gov/director/prog-ofc/report02-3.pdf
  2. [2] McConnell, Steve (2004). Code Complete, 2nd edition, Microsoft Press, 960. ISBN 0-7356-1967-0.