SlideShare una empresa de Scribd logo
1 de 35
Intro to
TDD with FlexUnit

            [ Anupom Syam ]
TDD Cycle
Why?

TDD is like Source Control you don’t know how
much you need it until you start using it.
Benefits?
• Test first approach is Aspect Driven
• Enforces the developer to be the first consumer of
    their own program
•   Makes it easy to Refactor
•   Simplifies Integration Testing
•   Unit tests are living documentation of the system
•   Encourages modular design
•   Gives greater level of confidence in the code
•   Reduces debugging time
Terminology
       Assertion                                               Test Case
true false statements that are used to verify the   a set of conditions to determine the correctness of some
               behavior of the unit                                  functionalities of program




       Test Suite                                                   Fixture
  a set of tests that all share the same fixture     all the things that must be in place in order to run a test




Code Coverage                                         Fakes & Mocks
                                                    Dummy objects that simulates the behavior of complex,
percentage of a program tested by by a test suite
                                                                        real objects
Phases of a Test
                Set Up                         Exercise
               setting up the test        interact with the system under
                     fixture                             test




Blank State


              Tear Down                           Verify
                                             determine whether the
          tear down the test fixture to
                                           expected outcome has been
           return to the original state
                                                    obtained
What?
• A unit testing framework for Flex and
  ActionScript.
• Similar to JUnit - the original Java unit testing
  framework.
• Comes with a graphical test runner.
• Can test both Flex and AS3 projects
Let’s try a “Hello
World” unit test using
      FlexUnit
1. Create a new project
1. Create a new project
2. Create a new method

            package
            {
            	 import flash.display.Sprite;
            	
            	 public class Calculator extends Sprite
            	 {
            	 	 public function Calculator()
            	 	 {
            	 	 	
            	 	 }
            	 	
            	 	 public function add(x:int, y:int):int
            	 	 {
            	 	 	 return 0;
            	 	 }
            	 }
            }
3. Create a test case class
3. Create a test case class
3. Create a test case class
package flexUnitTests
                  {
                  	   import flexunit.framework.Assert;
                  	

3. Create a       	
                  	
                      public class CalculatorTest
                      {	 	

test case class
                  	   	   [Before]
                  	   	   public function setUp():void
                  	   	   {
                  	   	   }
                  	   	
                  	   	   [After]
                  	   	   public function tearDown():void
                  	   	   {
                  	   	   }
                  	   	
                  	   	   [BeforeClass]
                  	   	   public static function setUpBeforeClass():void
                  	   	   {
                  	   	   }
                  	   	
                  	   	   [AfterClass]
                  	   	   public static function tearDownAfterClass():void
                  	   	   {
                  	   	   }
                  	   	
                  	   	   [Test]
                  	   	   public function testAdd():void
                  	   	   {
                  	   	   	   Assert.fail("Test method Not yet implemented");
                  	   	   }
                  	   }
                  }
package flexUnitTests
                    {
                    	   import flexunit.framework.Assert;
                    	
                    	   public class CalculatorTest
                    	   {	 	

4. Create a         	
                    	
                        	
                        	
                            private var calculator:Calculator;



failing test case
                    	   	   [Before]
                    	   	   public function setUp():void
                    	   	   {
                    	   	   	   calculator = new Calculator();
                    	   	   }
                    	   	
                    	   	   [After]
                    	   	   public function tearDown():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [BeforeClass]
                    	   	   public static function setUpBeforeClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [AfterClass]
                    	   	   public static function tearDownAfterClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [Test]
                    	   	   public function testAdd():void
                    	   	   {
                    	   	   	   Assert.assertEquals(calculator.add(2, 3), 5);
                    	   	   }
                    	   }
5. Execute the test
5. Execute the test
5. Execute the test
6. Write the body of the method
          package
          {
          	   import flash.display.Sprite;
          	
          	   public class Calculator extends Sprite
          	   {
          	   	   public function Calculator()
          	   	   {
          	   	   	
          	   	   }
          	   	
          	   	   public function add(x:int, y:int):int
          	   	   {
          	   	   	   return x+y;
          	   	   }
          	   }
          }
7. Execute the test again
7. Execute the test again
7. Execute the test again
Good Job!
package flexUnitTests
                    {
                    	   import flexunit.framework.Assert;
                    	
                    	   public class CalculatorTest
                    	   {	 	

Components of       	
                    	
                        	
                        	
                            private var calculator:Calculator;



a Test Case Class
                    	   	   [Before]
                    	   	   public function setUp():void
                    	   	   {
                    	   	   	   calculator = new Calculator();
                    	   	   }
                    	   	
                    	   	   [After]
                    	   	   public function tearDown():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [BeforeClass]
                    	   	   public static function setUpBeforeClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [AfterClass]
                    	   	   public static function tearDownAfterClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [Test]
                    	   	   public function testAdd():void
                    	   	   {
                    	   	   	   Assert.assertEquals(calculator.add(2, 3), 5);
                    	   	   }
                    	   }
package flexUnitTests
                    {
                    	   import flexunit.framework.Assert;
                    	
                    	   public class CalculatorTest
                    	   {	 	

Components of       	
                    	
                        	
                        	
                            private var calculator:Calculator;



a Test Case Class
                    	   	   [Before]
                    	   	   public function setUp():void
                    	   	   {
                    	   	   	   calculator = new Calculator();
                    	   	   }
                    	   	
                    	   	   [After]
                    	   	   public function tearDown():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [BeforeClass]
                    	   	   public static function setUpBeforeClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [AfterClass]
                    	   	   public static function tearDownAfterClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [Test]
                    	   	   public function testAdd():void
                    	   	   {
                    	   	   	   Assert.assertEquals(calculator.add(2, 3), 5);
                    	   	   }
                    	   }
package flexUnitTests
                    {
                    	   import flexunit.framework.Assert;
                    	
                    	   public class CalculatorTest
                    	   {	 	

Components of       	
                    	
                        	
                        	
                            private var calculator:Calculator;



a Test Case Class
                    	   	   [Before]
                    	   	   public function setUp():void
                    	   	   {
                    	   	   	   calculator = new Calculator();
                    	   	   }
                    	   	
                    	   	   [After]
                    	   	   public function tearDown():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [BeforeClass]
                    	   	   public static function setUpBeforeClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [AfterClass]
                    	   	   public static function tearDownAfterClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [Test]
                    	   	   public function testAdd():void
                    	   	   {
                    	   	   	   Assert.assertEquals(calculator.add(2, 3), 5);
                    	   	   }
                    	   }
package flexUnitTests
                    {
                    	   import flexunit.framework.Assert;
                    	
                    	   public class CalculatorTest
                    	   {	 	

Components of       	
                    	
                        	
                        	
                            private var calculator:Calculator;



a Test Case Class
                    	   	   [Before]
                    	   	   public function setUp():void
                    	   	   {
                    	   	   	   calculator = new Calculator();
                    	   	   }
                    	   	
                    	   	   [After]
                    	   	   public function tearDown():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [BeforeClass]
                    	   	   public static function setUpBeforeClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [AfterClass]
                    	   	   public static function tearDownAfterClass():void
                    	   	   {
                    	   	   }
                    	   	
                    	   	   [Test]
                    	   	   public function testAdd():void
                    	   	   {
                    	   	   	   Assert.assertEquals(calculator.add(2, 3), 5);
                    	   	   }
                    	   }
Test Suite Class

          package flexUnitTests
          {
          	   import flexUnitTests.CalculatorTest;
          	
          	   [Suite]
          	   [RunWith("org.flexunit.runners.Suite")]
          	   public class CalculatorTestSuite
          	   {
          	   	   public var test1:flexUnitTests.CalculatorTest;
          	   	
          	   }
          }
Myths
•   TDD is a Golden Hammer
•   We will not need Testers any more
•   TDD eradicates bugs from the code
•   TDD ensures that the code is up to the
    requirement
Facts
• Don’t expect TDD to solve all of your
  problems.
• TDD reduces the amount of QA but we will
  still need Testers :)
• TDD may reduce number of bugs
• Tests might share the same blind spots as
  your code because of misunderstanding of
  requirements.
Useful Links
• FlexUnit
   http://www.flexunit.org/

• FlexUnit 4.0
   http://docs.flexunit.org/index.php?title=Main_Page

• A brief and beautiful overview of FlexUnit
   http://www.digitalprimates.net/author/codeslinger/2009/05/03/
   flexunit-4-in-360-seconds/

• A very good read
   http://www.amazon.com/Working-Effectively-Legacy-Michael-
   Feathers/dp/0131177052
Thank you!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Junit With Eclipse
Junit With EclipseJunit With Eclipse
Junit With Eclipse
 
JUnit Pioneer
JUnit PioneerJUnit Pioneer
JUnit Pioneer
 
Junit
JunitJunit
Junit
 
Testing with Junit4
Testing with Junit4Testing with Junit4
Testing with Junit4
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
New and improved: Coming changes to the unittest module
 	 New and improved: Coming changes to the unittest module 	 New and improved: Coming changes to the unittest module
New and improved: Coming changes to the unittest module
 
Cpp unit
Cpp unit Cpp unit
Cpp unit
 
Junit
JunitJunit
Junit
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
JUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit Tests
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
Junit 4.0
Junit 4.0Junit 4.0
Junit 4.0
 
Unit testing framework
Unit testing frameworkUnit testing framework
Unit testing framework
 
Logic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with EclipseLogic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with Eclipse
 
Junit tutorial
Junit tutorialJunit tutorial
Junit tutorial
 
Code Samples
Code SamplesCode Samples
Code Samples
 
Qtp commands
Qtp commandsQtp commands
Qtp commands
 
Testing Spring Applications
Testing Spring ApplicationsTesting Spring Applications
Testing Spring Applications
 
Hyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkitHyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkit
 

Destacado

Math syllabus 2010/11
Math syllabus 2010/11Math syllabus 2010/11
Math syllabus 2010/11mathman314
 
Math in the 21st century
Math in the 21st centuryMath in the 21st century
Math in the 21st centurymathman314
 
Van Tour 98 The Corps 2002
Van Tour 98 The Corps 2002Van Tour 98 The Corps 2002
Van Tour 98 The Corps 2002How Gregg
 
No More Homework
No More HomeworkNo More Homework
No More Homeworkmathman314
 
Van Tour 42 Maritimes 1997
Van Tour 42 Maritimes 1997Van Tour 42 Maritimes 1997
Van Tour 42 Maritimes 1997How Gregg
 
No More Homework, WOW
No More Homework, WOWNo More Homework, WOW
No More Homework, WOWmathman314
 
Roadtrek Show
Roadtrek ShowRoadtrek Show
Roadtrek ShowHow Gregg
 
Cue to You Doc Camera Presentation
Cue to You Doc Camera PresentationCue to You Doc Camera Presentation
Cue to You Doc Camera Presentationmathman314
 

Destacado (9)

Math syllabus 2010/11
Math syllabus 2010/11Math syllabus 2010/11
Math syllabus 2010/11
 
Math in the 21st century
Math in the 21st centuryMath in the 21st century
Math in the 21st century
 
Van Tour 98 The Corps 2002
Van Tour 98 The Corps 2002Van Tour 98 The Corps 2002
Van Tour 98 The Corps 2002
 
No More Homework
No More HomeworkNo More Homework
No More Homework
 
Van Tour 42 Maritimes 1997
Van Tour 42 Maritimes 1997Van Tour 42 Maritimes 1997
Van Tour 42 Maritimes 1997
 
No More Homework, WOW
No More Homework, WOWNo More Homework, WOW
No More Homework, WOW
 
Ch Walkthru
Ch WalkthruCh Walkthru
Ch Walkthru
 
Roadtrek Show
Roadtrek ShowRoadtrek Show
Roadtrek Show
 
Cue to You Doc Camera Presentation
Cue to You Doc Camera PresentationCue to You Doc Camera Presentation
Cue to You Doc Camera Presentation
 

Similar a Introduction to TDD with FlexUnit

Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightOpenDaylight
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdfgauravavam
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAhmed Ehab AbdulAziz
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Buşra Deniz, CSM
 
Description (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfDescription (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfrishabjain5053
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaRavikiran J
 
Android testing
Android testingAndroid testing
Android testingSean Tsai
 
Unit Testing - Nakov's Talk @ VarnaConf 2013
Unit Testing - Nakov's Talk @ VarnaConf 2013Unit Testing - Nakov's Talk @ VarnaConf 2013
Unit Testing - Nakov's Talk @ VarnaConf 2013Svetlin Nakov
 
Unit testing by Svetlin Nakov
Unit testing by Svetlin NakovUnit testing by Svetlin Nakov
Unit testing by Svetlin Nakovit-tour
 
Code Kata: String Calculator in Flex
Code Kata: String Calculator in FlexCode Kata: String Calculator in Flex
Code Kata: String Calculator in FlexChris Farrell
 

Similar a Introduction to TDD with FlexUnit (20)

8-testing.pptx
8-testing.pptx8-testing.pptx
8-testing.pptx
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TestNG vs Junit
TestNG vs JunitTestNG vs Junit
TestNG vs Junit
 
Junit
JunitJunit
Junit
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDD
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015
 
Description (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfDescription (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdf
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran Janardhana
 
Android testing
Android testingAndroid testing
Android testing
 
Unit Testing - Nakov's Talk @ VarnaConf 2013
Unit Testing - Nakov's Talk @ VarnaConf 2013Unit Testing - Nakov's Talk @ VarnaConf 2013
Unit Testing - Nakov's Talk @ VarnaConf 2013
 
Unit testing by Svetlin Nakov
Unit testing by Svetlin NakovUnit testing by Svetlin Nakov
Unit testing by Svetlin Nakov
 
Code Kata: String Calculator in Flex
Code Kata: String Calculator in FlexCode Kata: String Calculator in Flex
Code Kata: String Calculator in Flex
 
Python testing
Python  testingPython  testing
Python testing
 

Último

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
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

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
 
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...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
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...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Introduction to TDD with FlexUnit

  • 1. Intro to TDD with FlexUnit [ Anupom Syam ]
  • 2.
  • 4. Why? TDD is like Source Control you don’t know how much you need it until you start using it.
  • 5. Benefits? • Test first approach is Aspect Driven • Enforces the developer to be the first consumer of their own program • Makes it easy to Refactor • Simplifies Integration Testing • Unit tests are living documentation of the system • Encourages modular design • Gives greater level of confidence in the code • Reduces debugging time
  • 6. Terminology Assertion Test Case true false statements that are used to verify the a set of conditions to determine the correctness of some behavior of the unit functionalities of program Test Suite Fixture a set of tests that all share the same fixture all the things that must be in place in order to run a test Code Coverage Fakes & Mocks Dummy objects that simulates the behavior of complex, percentage of a program tested by by a test suite real objects
  • 7. Phases of a Test Set Up Exercise setting up the test interact with the system under fixture test Blank State Tear Down Verify determine whether the tear down the test fixture to expected outcome has been return to the original state obtained
  • 8.
  • 9. What? • A unit testing framework for Flex and ActionScript. • Similar to JUnit - the original Java unit testing framework. • Comes with a graphical test runner. • Can test both Flex and AS3 projects
  • 10. Let’s try a “Hello World” unit test using FlexUnit
  • 11. 1. Create a new project
  • 12. 1. Create a new project
  • 13. 2. Create a new method package { import flash.display.Sprite; public class Calculator extends Sprite { public function Calculator() { } public function add(x:int, y:int):int { return 0; } } }
  • 14. 3. Create a test case class
  • 15. 3. Create a test case class
  • 16. 3. Create a test case class
  • 17. package flexUnitTests { import flexunit.framework.Assert; 3. Create a public class CalculatorTest { test case class [Before] public function setUp():void { } [After] public function tearDown():void { } [BeforeClass] public static function setUpBeforeClass():void { } [AfterClass] public static function tearDownAfterClass():void { } [Test] public function testAdd():void { Assert.fail("Test method Not yet implemented"); } } }
  • 18. package flexUnitTests { import flexunit.framework.Assert; public class CalculatorTest { 4. Create a private var calculator:Calculator; failing test case [Before] public function setUp():void { calculator = new Calculator(); } [After] public function tearDown():void { } [BeforeClass] public static function setUpBeforeClass():void { } [AfterClass] public static function tearDownAfterClass():void { } [Test] public function testAdd():void { Assert.assertEquals(calculator.add(2, 3), 5); } }
  • 22. 6. Write the body of the method package { import flash.display.Sprite; public class Calculator extends Sprite { public function Calculator() { } public function add(x:int, y:int):int { return x+y; } } }
  • 23. 7. Execute the test again
  • 24. 7. Execute the test again
  • 25. 7. Execute the test again
  • 27. package flexUnitTests { import flexunit.framework.Assert; public class CalculatorTest { Components of private var calculator:Calculator; a Test Case Class [Before] public function setUp():void { calculator = new Calculator(); } [After] public function tearDown():void { } [BeforeClass] public static function setUpBeforeClass():void { } [AfterClass] public static function tearDownAfterClass():void { } [Test] public function testAdd():void { Assert.assertEquals(calculator.add(2, 3), 5); } }
  • 28. package flexUnitTests { import flexunit.framework.Assert; public class CalculatorTest { Components of private var calculator:Calculator; a Test Case Class [Before] public function setUp():void { calculator = new Calculator(); } [After] public function tearDown():void { } [BeforeClass] public static function setUpBeforeClass():void { } [AfterClass] public static function tearDownAfterClass():void { } [Test] public function testAdd():void { Assert.assertEquals(calculator.add(2, 3), 5); } }
  • 29. package flexUnitTests { import flexunit.framework.Assert; public class CalculatorTest { Components of private var calculator:Calculator; a Test Case Class [Before] public function setUp():void { calculator = new Calculator(); } [After] public function tearDown():void { } [BeforeClass] public static function setUpBeforeClass():void { } [AfterClass] public static function tearDownAfterClass():void { } [Test] public function testAdd():void { Assert.assertEquals(calculator.add(2, 3), 5); } }
  • 30. package flexUnitTests { import flexunit.framework.Assert; public class CalculatorTest { Components of private var calculator:Calculator; a Test Case Class [Before] public function setUp():void { calculator = new Calculator(); } [After] public function tearDown():void { } [BeforeClass] public static function setUpBeforeClass():void { } [AfterClass] public static function tearDownAfterClass():void { } [Test] public function testAdd():void { Assert.assertEquals(calculator.add(2, 3), 5); } }
  • 31. Test Suite Class package flexUnitTests { import flexUnitTests.CalculatorTest; [Suite] [RunWith("org.flexunit.runners.Suite")] public class CalculatorTestSuite { public var test1:flexUnitTests.CalculatorTest; } }
  • 32. Myths • TDD is a Golden Hammer • We will not need Testers any more • TDD eradicates bugs from the code • TDD ensures that the code is up to the requirement
  • 33. Facts • Don’t expect TDD to solve all of your problems. • TDD reduces the amount of QA but we will still need Testers :) • TDD may reduce number of bugs • Tests might share the same blind spots as your code because of misunderstanding of requirements.
  • 34. Useful Links • FlexUnit http://www.flexunit.org/ • FlexUnit 4.0 http://docs.flexunit.org/index.php?title=Main_Page • A brief and beautiful overview of FlexUnit http://www.digitalprimates.net/author/codeslinger/2009/05/03/ flexunit-4-in-360-seconds/ • A very good read http://www.amazon.com/Working-Effectively-Legacy-Michael- Feathers/dp/0131177052

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n