Unit Tests Руслан Трифонов Omegasoft Ltd.. Съдържание 1.Въведение 2.Unit test patterns 2.1. Pass/fail patterns 2.2. Collection management patterns 2.3.

Slides:



Advertisements
Similar presentations
Unit-Testing Presented by Benny Pasternak November 2005 Program testing can be used to show the presence of bugs, but never to show their absence! - Edsger.
Advertisements

Extreme Programming Alexander Kanavin Lappeenranta University of Technology.
Test-Driven Development. Why Testing is Important? “If you don’t have tests, how do you know your code is doing the thing right and doing the right thing?”
Taking a Waterfall Project Agile REF: Paul Geberth GCSS-J Project Manager Establishment of an Agile Project.
Effectively Prioritizing Tests in Development Environment
Software Failure: Reasons Incorrect, missing, impossible requirements * Requirement validation. Incorrect specification * Specification verification. Faulty.
How to: Design and Develop an Application to Ensure its Quality James Hippolite Senior.NET Developer Telecom New Zealand Limited James Hippolite Senior.NET.
Roadmap to Continuous Integration Testing and Benefits Gowri Selka, Walgreens Natalie Koltun, Walgreens May 20th, 2014 ©2013 Walgreen Co. All rights reserved.
Component 4: Introduction to Information and Computer Science Unit 9: Components and Development of Large Scale Systems Lecture 5 This material was developed.
SE 450 Software Processes & Product Metrics Reliability: An Introduction.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Extreme Programming Team Members Gowri Devi Yalamanchi Sandhya Ravi.
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
Advance Unit Test, Part V -Unit Test Patterns By Marc Clifton Presentation By Yasir Ibrahim.
Test Driven Development Derived from Dr. Fawcett’s notes Phil Pratt-Szeliga Fall 2009.
Introduction to Computer Technology
Introduction to Continuous Integration Mike Roberts.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Extreme Programming Software Development Written by Sanjay Kumar.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
Categories of Testing.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Testing in Extreme Programming
EXtreme Programming: An Introduction Presentation by: Jon Banta.
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Databases and Statistical Databases Session 4 Mark Viney Australian Bureau of Statistics 5 June 2007.
© Logicalis Group Using DB2/400 effectively. Data integrity facilities Traditional iSeries database usage Applications are responsible for data integrity.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Unit Testing Building Rock-Solid Software SoftUni Team Technical Trainers Software University
Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University
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.
XP Overview Short Life cycle Risky / Dynamic Requirements Increase developer productivity.
Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
DBT544. DB2/400 Advanced Features Level Check Considerations Database Constraints File Overrides Object and Record Locks Trigger Programs.
Chapter 8 Lecture 1 Software Testing. Program testing Testing is intended to show that a program does what it is intended to do and to discover program.
Confidential Continuous Integration Framework (CIF) 5/18/2004.
Software Testing Process By: M. Muzaffar Hameed.
Phase Test Preperation. Getting a Clearer Picture Getting to a stage where we understand the problem more clearly Event tables Use case diagrams / descriptions.
EMBEDDED REAL-TIME, INC. December 8, 2015 Java Unit Mark Mosher Rochester Java Users Group.
Test Driven Development Daniel Brown dxb17u. Introduction Originates from Extreme Programming (XP) Proposed by Kent Beck in Test Driven Development.
1 Presentation Title Test-driven development (TDD) Overview David Wu.
Alcatel-Lucent CDC Workshop, Coaching & Knowledge Transfer Genesis.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
(1) Test Driven Development Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
Software Testing Mehwish Shafiq. Testing Testing is carried out to validate and verify the piece developed in order to give user a confidence to use reliable.
CSC 480 Software Engineering Extreme Programming.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
CS223: Software Engineering Lecture 19: Unit Testing.
Test-Driven Development Learn the "Test First" Approach to Coding Svetlin Nakov Technical Trainer Software University
Introduction to Software Engineering Muhammad Nasir Agile Software Development(2)
D E P A R T M E N T O F COMPUTER SCIENCE AND SYSTEMS ANALYSIS SCHOOL OF ENGINEERING & APPLIED SCIENCE O X F O R D O H I O MIAMI UNIVERSITY Software Testing.
Software Development Life Cycle. The Software Life Cycle  Encompasses all activities from initial analysis until end of work  Formal process for software.
Software Testing.
Test-Driven Development
CS223: Software Engineering
Introduction to Unit Testing in JavaScript
Quality Assurance: Early Work Items
Planning User stories are written.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Unit Test Pattern.
X in [Integration, Delivery, Deployment]
Test-first development
Component Testing (Unit Testing)
Lecture 09:Software Testing
Testing and Test-Driven Development CSC 4700 Software Engineering
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
Chapter 3 – Agile Software Development
IMPORTANT NOTICE TO STUDENTS:
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
Presentation transcript:

Unit Tests Руслан Трифонов Omegasoft Ltd.

Съдържание 1.Въведение 2.Unit test patterns 2.1. Pass/fail patterns 2.2. Collection management patterns 2.3. Data driven patterns 2.4. Data transaction patterns 2.5. Performance patterns 2.6. Process patterns 2.7. Simulation patterns 2.8. Stress test patterns 3.Ресурси

Definition A unit test is a piece of code written by a developer that exercises a very small, specific area of functionality of the code being tested.

Scope Design Development Test and Fix Time flow Planning Unit Testing System Testing Integration Testing Functional Testing Release Testing Unit Tests and Application Lifecycle

Unit test framework is needed.Unit test framework is needed. Unit tests are written by developers for developersUnit tests are written by developers for developers Unit tests are released into the code repository along with the code they testUnit tests are released into the code repository along with the code they test Some facts

Trivial code may be omitted (property getters and setters)Trivial code may be omitted (property getters and setters) Ideally all unit tests should pass before check-inIdeally all unit tests should pass before check-in More facts

Code and TestCode and Test Test FirstTest First Unit Testing Approach

Write code Write unit test Run and succeed Code and Test Time flow

Pick а test Compile and Fail Write code to pass test Write enough code to compile Run test and fail Create a test list Test Driven Development Time flow Write test Remove duplication

Why TDD? Helps find design issues early and avoids reworkHelps find design issues early and avoids rework Writing code to satisfy a test is a focused activity – less chance of errorWriting code to satisfy a test is a focused activity – less chance of error Tests will be a more comprehensive than when written after codeTests will be a more comprehensive than when written after code

Unit tests improve designUnit tests improve design Unit tests are good documentationUnit tests are good documentation Unit tests enable collective code ownershipUnit tests enable collective code ownership Why Unit Tests?

Unit tests decrease the defect-injection rate due to refactoring / changesUnit tests decrease the defect-injection rate due to refactoring / changes Unit tests decrease the cost of the changesUnit tests decrease the cost of the changes Unit tests bring higher development velocity in the latest dev. stagesUnit tests bring higher development velocity in the latest dev. stages Unit tests enable frequent integrationUnit tests enable frequent integration

Development Workstation Source Code Repository Server Integration Server Publish Results Continuous Integration Check out Build Perform BVT Publish results Check-in

Why Continuous Integration? The time to integrate is a function of the time between two subsequent integrations Faster and cheaper integration processFaster and cheaper integration process Faster integration error recoveryFaster integration error recovery

Scaling Up Real Life ExampleReal Life Example Company SAS Institute Developers ~800 Environment Java, *Cruise control, CVS Code size ~ loc 3 CVS Branches of 5 million loc each

Unit Test Patterns

Pass/fail patterns The Simple-Test PatternThe Simple-Test Pattern The Code-Path PatternThe Code-Path Pattern The Parameter-Range PatternThe Parameter-Range Pattern

The Simple-Test Pattern Condition A Condition B Code Expected Result Expected Failure

The Code-Path Pattern Code Path A Code Path B Code Paths Path Result

The Parameter-Range Pattern Code Path A Code Path B Code Paths Path Result Success Set Failure Set

Collection management patterns The Collection-Order PatternThe Collection-Order Pattern The Enumeration PatternThe Enumeration Pattern The Collection-Constraint PatternThe Collection-Constraint Pattern The Collection-Indexing PatternThe Collection-Indexing Pattern

The Collection-Order Pattern Unordered Data Code Containing Collection Unordered Sequenced Ordered

The Enumeration Pattern Enumerator (Fwd, Rev) Code Containing Collection Edged Test Collection Expected Datum

The Collection-Constraint Pattern Null Value Collection Container Write Test Constraints Unique

The Collection-Indexing Pattern Index Key Collection Container Write Test Index Tests Out Of Bounds Index Update/Delete by Index

Data driven patterns The Simple-Test-Data PatternThe Simple-Test-Data Pattern The Data-Transformation-Test PatternThe Data-Transformation-Test Pattern

The Simple-Test-Data Pattern Input Verify Results Computation Code Output Unit Test Data Set

The Data-Transformation-Test Pattern Input Data Set Measurements Transformation Code Validation Unit Test

Data Transaction patterns The Simple-Data-I/O PatternThe Simple-Data-I/O Pattern The Constraint-Data PatternThe Constraint-Data Pattern The Rollback PatternThe Rollback Pattern

The Simple-Data-I/O Pattern Service Read Test Write Test

The Constraint-Data Pattern Nullable Service Write Test Constraints Unique Default Value Foreign Key Cascading Update Default Delete

The Rollback Pattern Service Known State Write Test rollback

Performance Patterns The Performance-Test PatternThe Performance-Test Pattern

The Performance-Test Pattern Metric At Start Code Pass Fail Metric At End Pass criteria

Simulation patterns Mock-Object PatternMock-Object Pattern The Service-Simulation PatternThe Service-Simulation Pattern The Component-Simulation PatternThe Component-Simulation Pattern

Mock-Object Pattern Abstract Methods Mock Object Implementation Real Access Layer Implementation Factory Mode Instantiates one of

The Service-Simulation Pattern Test Code Simulated Service Test I/O

The Component-Simulation Pattern Recovery Code Component Failure Test Timeout

Stress test patterns The Bulk-Data-Stress-Test PatternThe Bulk-Data-Stress-Test Pattern The Resource-Stress-Test PatternThe Resource-Stress-Test Pattern The Loading-Test PatternThe Loading-Test Pattern

The Bulk-Data-Stress-Test Pattern Data Manipulation Data Process Pass Fail Bulk Data Performance Metric

The Resource-Stress-Test Pattern Test Code Set Resource

The Loading-Test Pattern Test Code Loading

Useful links Extreme Programming Extreme Programming XP Programming Unit Test Patterns Unit Test Patterns Continuous Integration Continuous Integration ml Darrell Norton’s Blog Darrell Norton’s Blog 7.aspx

Q & A