SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
Preventing Bugs with Unit Testing
Chapter 5 - Coder to Developer by Mike Gunderloy
Instructor : Dr.James Fawcett
Presented by
Priyaa Nachimuthu
priyaa@syr.edu
Agenda
 Types of Testing
 Testing for Developers
 Unit Testing
 Using NUnit
 Test – Driven Development
 Refactoring
 Unit Testing Summary
Types of Testing
 Unit Testing – testing very small pieces of code
 Integration Testing - code doesn't break someone else’s code
 System Testing – exercising the entire application to make it fail
 Stress Testing – push the limits of the application until it fails
 Beta Testing – giving copies of the unfinished code to outside
testers for feedback
 Acceptance Testing – formal verification of requirements
Testing for Developers
 Check out the module
 Write the code for the next feature to be implemented
 Write unit tests to test the feature
 Ensure that the code passes the unit tests
 Get the latest code for the entire application
 Make sure the whole project passes the integration tests
 Check in code and unit tests
Unit Testing
 JUnit – by Erich Gamma and Kent Beck for Java development
 NUnit – free, open source framework, a .Net unit testing
tool.NUnitAddin,TestRunner for NUnit integrates NUnit with VS.Net.NUnitAsp
supports NUnit testing of ASP. Net pages. ( http://nunit.org )
 csUnit – free, open-source implementation. Additional features, includes project
wizards to build new testing projects easily and a UI with more information. (
http://csunit.org )
 HarnessIt - $199.Pluaggable test engine architecture. Easy testing of web and
remote applications using the same tools as local windows applications.(
www.unittesting.com/default.aspx )
 X-Unity - $129.VS.Net integration, a development kit for unit tests, and
integration ( http://x-unity.miik.com.ua/ )
 .TEST - $900.Writes many unit tests for the user. Uses rules-based engine to
ensure code correctness and allows the user to write custom tests.(
www.parasoft.com/jsp/products/home.jsp?product=TestNet )
Using NUnit for Unit Testing
 A simple test
 Debugging NUnit tests
 Testing an exception
 Testing with mock objects
Test Driven Development
 A new testing technique by advocates of Extreme
Programming.
 Introduction to TDD : “Test-Driven Development”
by Kent Beck.
 Two simple rules
- Write a failing automated test before writing
any code
- Remove duplication
TDD – Plan of Action
 Quickly add a test
 Run all tests and see the new one fail
 Make a little change
 Run all tests and see them all succeed
 Refactor to remove duplication
TDD in Action
 Code Sample
Refactoring
 Martin Fowler’s Refactoring : Improving the Design of
the existing Code
 The process of changing a software system in such a
way that it doesn't alter the external behavior of the
code yet improves its internal structure.
 Refactoring patterns
 Code Thrashing – developers with different ideas
Refactoring Tools
 dotEasy – free ( www.doteasy.com.uy/ )
 The C# Refactoring Tool - $110 (
http://dotnetrefactoring.com/ )
 C# Refactory - $99 ( www.xtreme-
simplicity.net/CSharpReFactory.html )
 FlyWheel - $449 ( www.velocitis.com/ )
Unit Testing Checklist
 Write unit tests for all code
 Don’t postpone the tests
 Ensure that the code passes unit tests and integration tests
before check-ins
 Use automated tools such as NUnit
 Check the tests and any other setup files into SCC
 Consider using TDD for 100% coverage
 Refactor code only when there are thorough set of tests for the
code
Thank you!

More Related Content

PPT
Unit Testing
PPTX
Understanding Unit Testing
PPTX
Unit Testing And Mocking
PPTX
Unit tests & TDD
PPTX
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
PPTX
An Introduction to Unit Testing
PPS
Unit Testing
PDF
Unit and integration Testing
Unit Testing
Understanding Unit Testing
Unit Testing And Mocking
Unit tests & TDD
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
An Introduction to Unit Testing
Unit Testing
Unit and integration Testing

What's hot (20)

PPTX
Software Quality via Unit Testing
PPTX
Unit Tests And Automated Testing
PPTX
Unit Testing Concepts and Best Practices
PPTX
Unit testing
PPTX
Unit Testing
PPTX
PPTX
Benefit From Unit Testing In The Real World
PDF
Clean Unit Test Patterns
PPTX
Unit Testing (C#)
PPTX
Test driven development in .Net - 2010 + Eclipse
PPTX
Unit testing
ODP
Beginners - Get Started With Unit Testing in .NET
PDF
Unit Testing Fundamentals
PPSX
Unit Test Presentation
PDF
Unit Testing 101
KEY
Unit Testing Your Application
PPTX
Mock driven development using .NET
PPTX
Unit test
PPTX
Unit testing
PPTX
Moq presentation
Software Quality via Unit Testing
Unit Tests And Automated Testing
Unit Testing Concepts and Best Practices
Unit testing
Unit Testing
Benefit From Unit Testing In The Real World
Clean Unit Test Patterns
Unit Testing (C#)
Test driven development in .Net - 2010 + Eclipse
Unit testing
Beginners - Get Started With Unit Testing in .NET
Unit Testing Fundamentals
Unit Test Presentation
Unit Testing 101
Unit Testing Your Application
Mock driven development using .NET
Unit test
Unit testing
Moq presentation
Ad

Similar to Unit testing (20)

PPTX
Test-Driven-Development.pptx
PPTX
TDD - Agile
PDF
Back to basics - PHPUnit
PPTX
Unit Testing
PDF
TDD Workshop UTN 2012
PPTX
Software presentation
PDF
Introduction of unit test to management
PPTX
Agile Engineering Sparker GLASScon 2015
PPTX
Test Driven Development
PDF
Unit Testing to Support Reusable for Component-Based Software Engineering
PPTX
Test driven development(tdd)
PPTX
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
DOCX
Test driven development and unit testing with examples in C++
PPTX
Test Driven Development
PPTX
Unit testing & TDD concepts with best practice guidelines.
PPTX
Loopt unit test experiences
PPTX
Getting Started with Test-Driven Development at Longhorn PHP 2023
PPT
Automated Testing with Agile
PPTX
Automation testing & Unit testing
PPT
Automated Software Testing Framework Training by Quontra Solutions
Test-Driven-Development.pptx
TDD - Agile
Back to basics - PHPUnit
Unit Testing
TDD Workshop UTN 2012
Software presentation
Introduction of unit test to management
Agile Engineering Sparker GLASScon 2015
Test Driven Development
Unit Testing to Support Reusable for Component-Based Software Engineering
Test driven development(tdd)
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Test driven development and unit testing with examples in C++
Test Driven Development
Unit testing & TDD concepts with best practice guidelines.
Loopt unit test experiences
Getting Started with Test-Driven Development at Longhorn PHP 2023
Automated Testing with Agile
Automation testing & Unit testing
Automated Software Testing Framework Training by Quontra Solutions
Ad

Recently uploaded (20)

PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
web development for engineering and engineering
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
PPT on Performance Review to get promotions
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
additive manufacturing of ss316l using mig welding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Foundation to blockchain - A guide to Blockchain Tech
Strings in CPP - Strings in C++ are sequences of characters used to store and...
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Arduino robotics embedded978-1-4302-3184-4.pdf
OOP with Java - Java Introduction (Basics)
Structs to JSON How Go Powers REST APIs.pdf
CH1 Production IntroductoryConcepts.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
web development for engineering and engineering
Embodied AI: Ushering in the Next Era of Intelligent Systems
Mechanical Engineering MATERIALS Selection
UNIT 4 Total Quality Management .pptx
Sustainable Sites - Green Building Construction
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT on Performance Review to get promotions
Internet of Things (IOT) - A guide to understanding
additive manufacturing of ss316l using mig welding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
CYBER-CRIMES AND SECURITY A guide to understanding
Foundation to blockchain - A guide to Blockchain Tech

Unit testing

  • 1. Preventing Bugs with Unit Testing Chapter 5 - Coder to Developer by Mike Gunderloy Instructor : Dr.James Fawcett Presented by Priyaa Nachimuthu priyaa@syr.edu
  • 2. Agenda  Types of Testing  Testing for Developers  Unit Testing  Using NUnit  Test – Driven Development  Refactoring  Unit Testing Summary
  • 3. Types of Testing  Unit Testing – testing very small pieces of code  Integration Testing - code doesn't break someone else’s code  System Testing – exercising the entire application to make it fail  Stress Testing – push the limits of the application until it fails  Beta Testing – giving copies of the unfinished code to outside testers for feedback  Acceptance Testing – formal verification of requirements
  • 4. Testing for Developers  Check out the module  Write the code for the next feature to be implemented  Write unit tests to test the feature  Ensure that the code passes the unit tests  Get the latest code for the entire application  Make sure the whole project passes the integration tests  Check in code and unit tests
  • 5. Unit Testing  JUnit – by Erich Gamma and Kent Beck for Java development  NUnit – free, open source framework, a .Net unit testing tool.NUnitAddin,TestRunner for NUnit integrates NUnit with VS.Net.NUnitAsp supports NUnit testing of ASP. Net pages. ( http://nunit.org )  csUnit – free, open-source implementation. Additional features, includes project wizards to build new testing projects easily and a UI with more information. ( http://csunit.org )  HarnessIt - $199.Pluaggable test engine architecture. Easy testing of web and remote applications using the same tools as local windows applications.( www.unittesting.com/default.aspx )  X-Unity - $129.VS.Net integration, a development kit for unit tests, and integration ( http://x-unity.miik.com.ua/ )  .TEST - $900.Writes many unit tests for the user. Uses rules-based engine to ensure code correctness and allows the user to write custom tests.( www.parasoft.com/jsp/products/home.jsp?product=TestNet )
  • 6. Using NUnit for Unit Testing  A simple test  Debugging NUnit tests  Testing an exception  Testing with mock objects
  • 7. Test Driven Development  A new testing technique by advocates of Extreme Programming.  Introduction to TDD : “Test-Driven Development” by Kent Beck.  Two simple rules - Write a failing automated test before writing any code - Remove duplication
  • 8. TDD – Plan of Action  Quickly add a test  Run all tests and see the new one fail  Make a little change  Run all tests and see them all succeed  Refactor to remove duplication
  • 9. TDD in Action  Code Sample
  • 10. Refactoring  Martin Fowler’s Refactoring : Improving the Design of the existing Code  The process of changing a software system in such a way that it doesn't alter the external behavior of the code yet improves its internal structure.  Refactoring patterns  Code Thrashing – developers with different ideas
  • 11. Refactoring Tools  dotEasy – free ( www.doteasy.com.uy/ )  The C# Refactoring Tool - $110 ( http://dotnetrefactoring.com/ )  C# Refactory - $99 ( www.xtreme- simplicity.net/CSharpReFactory.html )  FlyWheel - $449 ( www.velocitis.com/ )
  • 12. Unit Testing Checklist  Write unit tests for all code  Don’t postpone the tests  Ensure that the code passes unit tests and integration tests before check-ins  Use automated tools such as NUnit  Check the tests and any other setup files into SCC  Consider using TDD for 100% coverage  Refactor code only when there are thorough set of tests for the code