SlideShare a Scribd company logo
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!

More Related Content

What's hot

Junit With Eclipse
Junit With EclipseJunit With Eclipse
Junit With Eclipse
Sunil kumar Mohanty
 
JUnit Pioneer
JUnit PioneerJUnit Pioneer
JUnit Pioneer
Scott Leberknight
 
Junit
JunitJunit
Testing with Junit4
Testing with Junit4Testing with Junit4
Testing with Junit4
Amila Paranawithana
 
Test driven development
Test driven developmentTest driven development
Test driven development
christoforosnalmpantis
 
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
PyCon Italia
 
Cpp unit
Cpp unit Cpp unit
Cpp unit
mudabbirwarsi
 
Junit
JunitJunit
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
Anton Udovychenko
 
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
John Ferguson Smart Limited
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
Nayanda Haberty
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
Renato Primavera
 
Junit 4.0
Junit 4.0Junit 4.0
Unit testing framework
Unit testing frameworkUnit testing framework
Unit testing framework
Igor Vavrish
 
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
Coen De Roover
 
Junit tutorial
Junit tutorialJunit tutorial
Junit tutorial
Main Uddin Patowary
 
Code Samples
Code SamplesCode Samples
Code Samples
Bill La Forge
 
Qtp commands
Qtp commandsQtp commands
Qtp commands
G.C Reddy
 
Testing Spring Applications
Testing Spring ApplicationsTesting Spring Applications
Testing Spring Applications
Muhammad Abdullah
 
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
7mind
 

What's hot (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
 

Viewers also liked

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

Viewers also liked (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 to Introduction to TDD with FlexUnit

8-testing.pptx
8-testing.pptx8-testing.pptx
8-testing.pptx
ssuserd0fdaa
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
Pokpitch Patcharadamrongkul
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
OpenDaylight
 
Java Programs
Java ProgramsJava Programs
Java Programs
vvpadhu
 
31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf
gauravavam
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Anand Kumar Rajana
 
TestNG vs Junit
TestNG vs JunitTestNG vs Junit
TestNG vs Junit
Büşra İçöz
 
Junit
JunitJunit
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
Ahmed Ehab AbdulAziz
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
Priya Sharma
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
priya_trivedi
 
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
Buş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.pdf
rishabjain5053
 
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
Ravikiran J
 
Android testing
Android testingAndroid testing
Android testing
Sean 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 2013
Svetlin Nakov
 
Unit testing by Svetlin Nakov
Unit testing by Svetlin NakovUnit testing by Svetlin Nakov
Unit testing by Svetlin Nakov
it-tour
 
Code Kata: String Calculator in Flex
Code Kata: String Calculator in FlexCode Kata: String Calculator in Flex
Code Kata: String Calculator in Flex
Chris Farrell
 
Python testing
Python  testingPython  testing
Python testing
John(Qiang) Zhang
 

Similar to 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
 

Recently uploaded

"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 

Recently uploaded (20)

"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 

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

Editor's Notes

  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