Unit Testing - solid fundamentals

Slides:



Advertisements
Similar presentations
xUnit Test Patterns (Some) xUnit Test Patterns (in practice) by Adam Czepil.
Advertisements

Test-Driven Development and Refactoring CPSC 315 – Programming Studio.
Unit Tests DEFINITION AND OVERVIEW by Paul M. code of the damned. com.
Tools for Agile Development: A Developer’s Perspective Mike Linnen Blog:
Testing and Debugging CS221 – 2/13/09. Airline Program.
Test-Driven Development and Refactoring Project 3 Lecture 1 CPSC 315 – Programming Studio Fall 2009.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Unit testing C# classes “If it isn’t tested it doesn’t work” Unit testing C# classes1.
Test-Driven Development “Test first, develop later!” –OCUnit.
XUnit Test Patterns writing good unit tests Peter Wiles.
TDD OVERVIEW OF TEST DRIVEN DEVELOPMENT by Paul M. code of the damned. com.
By for Test Driven Development: Industry practice and teaching tool Robert Vanderwall, Ph.D. 1 WISTPC-15.
© 2012 Autodesk Automated Testing with the AutoCAD ®.NET API Scott McFarlane Senior Software Engineer, Woolpert, Inc.
Test-Driven Development With Visual Studio 2005 Erno de Weerd Info Support.
TDD,BDD and Unit Testing in Ruby
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
Introduction to Unit Testing Jun-Ru Chang 2012/05/03.
Continuous Integration and Testing
Test automation / JUnit Building automatically repeatable test suites.
Software testing Main issues: There are a great many testing techniques Often, only the final code is tested.
Refactoring for Testability (or how I learned to stop worrying and love failing tests) Presented by Aaron Evans.
TEST-1 6. Testing & Refactoring. TEST-2 How we create classes? We think about what a class must do We focus on its implementation We write fields We write.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
Refactoring & Testability. Testing in OOP programming No life in flexible methodologies and for refactoring- infected developers without SOME kind of.
Test-Driven Development Eduard Miric ă. The problem.
Test Stubs... getting the world under control. TDD of State Pattern To implement GammaTown requirements I CS, AUHenrik Bærbak Christensen2.
Test it! Unit, mocking and in-container Meet Arquillian! Ivan St. Ivanov.
Test Driven Development Introduction Issued date: 8/29/2007 Author: Nguyen Phuc Hai.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Beginning Software Craftsmanship Brendan Enrick Steve Smith
1 Punishment Through Continuous Delivery If it hurts, do it more often…
Test Plans Test Driven Development – Unit test plan first Code coverage Automated Regression built as you go Debug is easier Serves as system doc – Still.
Software Engineering Lecture 11 Software Testing Presenter: Josef Hallberg 1.
1 © Agitar Software, 2007 Automated Unit Testing with AgitarOne Presented by Eamon McCormick Senior Solutions Consultant, Agitar Software Inc. Presented.
Automated Software Testing
Overview Modern chip designs have multiple IP components with different process, voltage, temperature sensitivities Optimizing mix to different customer.
PHPUnit vs PHPSpec © Rudolf Horváth
Don Braffitt Updated: 26-Mar-2013
Test-driven development
TESTING TEST DRIVEN DEVELOPMENT
Better Unit Tests through Design Patterns: Repository, Adapter, Mocks, and more… Benjamin
Developer Testing Tricks
Introduction to Unit Testing in JavaScript
Object-oriented software testing
Continuous Integration and Testing
Putting Testing First CS 4501 / 6501 Software Testing
Test Driven Development
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
Chapter 8 – Software Testing
Software Testing.
TDD Overview CS 4501/6501 Software Testing
Unit Testing in a Team Sparkhound Presents by Steve Schaneville
Unit Testing & Test-Driven Development for Mere Mortals
Selenium HP Web Test Tool Training
Unit testing C# classes
Unit Testing & Test-Driven Development for Mere Mortals
(Test Driven) Software Development
History, Characteristics and Frameworks
Introduction to Software Testing
TDD adoption plan 11/20/2018.
Unit Testing with xUnit.net-Part-2
Testing and Test-Driven Development CSC 4700 Software Engineering
Sharing the good, the bad, the ugly & What can we do about it?
TDD & ATDD 1/15/2019.
Unit Testing & Test-Driven Development for Mere Mortals
Designing For Testability
Java & Testing.
Testing Strategies Sources: Code Complete, 2nd Ed., Steve McConnell
Robert Klar Greg Dunn Using a Test-Driven Development Approach for Space Mission Flight Software Robert Klar.
Test-Driven Development
Presentation transcript:

Unit Testing - solid fundamentals Milan Vukoje www.Vukoje.NET vukoje@gmail.com

Themes Why testing? Where to start? Basics & Examples What (not) to test? TDD Test Doubles

Average cost of defects Why testing? Coding is hard Stabilization phases Manual tests Complexity Missing specs Is it working? We hate software  Average cost of defects Construction 1 System test x10 Post release x10-25

The goal! Change fast Fail fast Executable specification Redefining “Done” Trust Automatization

What is UT? Code that verifies unit behavior A unit is the smallest testable part of an application. Written and run by software developers Unit vs. Integration tests

Where to start? Start small and enhance Mind shifting Test Driven Development: By Example – Kent Beck xUnit Test Patterns: Refactoring Test Code - Gerard Meszaros

Example [1] - Calculator

Unit Testing phases

Example [2] - Counter

What to unit test? Calculations State (initialization and transitions) Conditionals Loops Polymorphism & Operators Persistency Notifications Argument Validation? Exception throwing?

What NOT to unit test? Concurrency GUI? Performance? other people code .NET 3dh party libraries      

Example [3]

What is TDD? Discipline of writing unit tests before writing a single line of code. Goal: Clean code that works Way of managing fear. Phases Red Green Refactor

TDD Benefits Regression testing – not repeating same mistakes Test First vs. Test Last Full testability Full coverage Minimalistic implementation Micro increments Focus Tests as To Do list

Example [4]- Email

Fixture & DOC

Why Test Doubles? Class isolation Controlling SUT - indirect input No visible output – indirect output Setup simplification (DB) DOC doesn’t exist Communication testing Speed Easy teardown

Test Spy

Test Stub

Mock Object

Creating the Test Double Hand-Built Configurable Hard-Coded Dynamically Generated Forcing clean testable design Don’t go wild

Installing the Test Double Dependency Injection Setter injection Constructor Injection Parameter Injection Dependency Lookup Factory Factory Method Test Specific SUT subclass IoC Containers Encapsulation? User Fake Mail Manager Mail Manager

When? When to start UT? When to write tests? When to stop? Start on project start. When to write tests? Always… when you can afford When to stop? When fear transform to boredom. When to Run tests? While coding Before check-in On automated build

Limitations It’s a Change More Code Time Only show the presence of errors, not proving absence of errors. It will not catch integration errors How can we verify that tests are working correctly?

Summary Coding is hard Unit Tests can help greatly Start smart – small and evolve Go TDD Come to second presentation 

Questions?

Please fill the questionnaire ! You have a chance to win: Sponsored by:

Milan Vukoje www.Vukoje.NET vukoje@gmail.com Thanks! Milan Vukoje www.Vukoje.NET vukoje@gmail.com