SlideShare ist ein Scribd-Unternehmen logo
1 von 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!

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
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
 
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
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
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
 
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
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Kürzlich hochgeladen (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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...
 
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
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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
 
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...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

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

Hinweis der Redaktion

  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