Refactoring and Integration Testing or Strategy, introduced reliably by TDD The power of automated tests.

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
A Brief Introduction to Test- Driven Development Shawn M. Jones.
The System and Software Development Process Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Case Tools Trisha Cummings. Our Definition of CASE  CASE is the use of computer-based support in the software development process.  A CASE tool is a.
E-commerce Project Erik Zeitler Erik Zeitler2 Lab 2  Will be anounced and scheduled later  We will deploy Java Server Pages on a Tomcat server.
EXtreme.NET Dr. Neil Roodyn. eXtreme.NET Who is Dr. Neil? MISSION: To increase the value of your Software Business Working with software for way too long.
DAIMIHenrik Bærbak Christensen1 Mandatory Project Part II Software Reliability and Testing.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Applied Software Project Management 1 Introduction Dr. Mengxia Zhu Computer Science Department Southern Illinois University Carbondale.
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 17 Slide 1 Extreme Programming.
Chapter 3 – Agile Software Development 1Chapter 3 Agile software development.
Applied Software Project Management Andrew Stellman & Jennifer Greenehttp:// Applied Software Project Management Chapter 1: Introduction.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 6 Slide 1 Chapter 6 Requirements Engineering Process.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 6 Slide 1 Requirements Engineering Processes l Processes used to discover, analyse and.
Chapter 2 소프트웨어공학 Software Engineering 임현승 강원대학교
1 Software testing. 2 Testing Objectives Testing is a process of executing a program with the intent of finding an error. A good test case is in that.
Copyright © Software Carpentry 2012 This work is licensed under the Creative Commons Attribution License See
Extreme/Agile Programming Prabhaker Mateti. ACK These slides are collected from many authors along with a few of mine. Many thanks to all these authors.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Chapter 8 – Software Testing Part 2 1Chapter 8 Software testing.
Rapid software development 1. Topics covered Agile methods Extreme programming Rapid application development Software prototyping 2.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 1: Software and Software Engineering.
Software Construction Lecture 18 Software Testing.
A Practical Guide To Unit Testing John E. Boal TestDrivenDeveloper.com.
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.
Systems Analysis and Design in a Changing World, Fourth Edition
AP-1 4. Agile Processes. AP-2 Agile Processes Focus on creating a working system Different attitude on measuring progress XP Scrum.
Henrik Bærbak Christensen1 Frameworks / Product Lines The frame for reuse.
The HotCiv GUI Instantiating the MiniDraw Framework.
Refactoring - 1 CS494: Intro. to Refactoring Readings: –Refactoring for everyone: How and why to use Eclipse's automated refactoring features. By David.
Test Stubs... getting the world under control. TDD of State Pattern To implement GammaTown requirements I CS, AUHenrik Bærbak Christensen2.
Henrik Bærbak Christensen1 Test Driven Development “TDD” Summary.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Testing Spring Applications Unit Testing.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Henrik Bærbak Christensen1 Build Management Clean environment that works...
Ivar Jacobson, Grady Booch, and James Rumbaugh The Unified Software Development Process Addison Wesley, : James Rumbaugh's OOMD 1992: Ivar Jacobson's.
Henrik Bærbak Christensen1 Test Driven Development “TDD” A process focusing on reliability, progress, and confidence.
Extreme Programming. Extreme Programming (XP) Formulated in 1999 by Kent Beck, Ward Cunningham and Ron Jeffries Agile software development methodology.
Deriving State…...and an example of combining behaviour.
Phoenix Scrum User Group Simplifying Scrum Online May 21 st 2009.
Multi Dimensional Variance: How to make ultra flexible software!
Mandatory 1 / AlphaCiv … Traps to be aware of …. Warn or not? I once asked Kent Beck the following –I have a lot of students in a course in design patterns.
Applying the Principles Two Examples. Example 1 New Requirement It would be nice with a simple GUI “to see something” instead of just xUnit tests...
Test Driven Development Introduction Issued date: 8/29/2007 Author: Nguyen Phuc Hai.
Mandatory 1 / AlphaCiv … a few comments…. Overall: Generally – good work – good effort Seems you are generally doing TDD Minor hick-ups –”My own way is.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Continuous Improvement. Start Simple and Continually Improve E.g., Gmail Labels 1.
Strategy in 15 minutes... derived from the principles.
AU CSHenrik Bærbak Christensen1 dSoftArk E2013 Software Architecture Programming in the Large.
Lecturer: Eng. Mohamed Adam Isak PH.D Researcher in CS M.Sc. and B.Sc. of Information Technology Engineering, Lecturer in University of Somalia and Mogadishu.
Extreme programming (XP) Advanced Software Engineering Dr Nuha El-Khalili.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Software Development. The Software Life Cycle Encompasses all activities from initial analysis until obsolescence Analysis of problem or request Analysis.
Information Systems Development
Software Development.
Instantiating the MiniDraw Framework
Applying the Principles
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
Mandatory 1 / AlphaCiv … Traps to be aware of ….
Test-Driven Development
Extreme Programming.
Baisc Of Software Testing
Software Verification, Validation, and Acceptance Testing
Software Engineering and Architecture
Software Development Techniques
Software Engineering and Architecture
Presentation transcript:

Refactoring and Integration Testing or Strategy, introduced reliably by TDD The power of automated tests

Two product variants Alphatown and Betatown –Four models to handle this compositional proposal has nice properties... How do we introduce it? AUHenrik Bærbak Christensen2

Change by addition I state: Change by addition, not modification because –addition little to test, little to review little chance of introducing ripple-effects –modification more to test, more to review high risk of ripples leading to side effects (bugs!) AUHenrik Bærbak Christensen3

The Problem Statement But I have to modify the pay station implementation in order to prepare it for the new compositional design that uses a Strategy pattern  Change by modification Problem: –How to reliably modify PayStationImpl? –How can I stay confident that I do not accidentally introduce any defects? AUHenrik Bærbak Christensen4

Take Small Steps I will stay focused and take small steps! I have two tasks –1) Redesign the current implementation to introduce the Strategy and make AlphaTown work with new design –2) Add a new strategy to handle Betatown requirements... and I will do it in that order – small steps! AUHenrik Bærbak Christensen5

Refactoring Definition: Refactoring is the process of changing a software system in such a way that is does not alter the external behaviour of the code yet improves its internal structure. Fowler, 1999 AUHenrik Bærbak Christensen6

Iteration 1 Refactoring step

The Rhythm AUHenrik Bærbak Christensen8 Refactoring and the rhythm Same spirit, but step 1: refactor

A faster way than the book Use the tools in your IDE AUHenrik Bærbak Christensen9

Simply type what you want And guide your IDE while it suggests quick fixes! AUHenrik Bærbak Christensen10

Discussion AUHenrik Bærbak Christensen11

Why TDD? Traditionally, developers see tests as –boring –time consuming Why? Because of the stakeholders that benefit from tests are not the developers –customers: ensure they get right product –management: measure developer productivity –test department: job security –developers: no benefit at all  AUHenrik Bærbak Christensen12

If it ain’t broke... If it ain’t broke, don’t fix it is the old saying of fear-driven programming Developers and programmers do not dare doing drastic design and architecture changes in fear of odd side-effects. AUHenrik Bærbak Christensen13

Test Ownership Refactoring make developers want to have ownership of the tests: Automatic tests is the developers’ means to be courageous and dare modify existing production code. AUHenrik Bærbak Christensen14

When redesigning.... TDD often seems like a nuisance to students and developers until the first time they realize that they dare do things they previously never dreamed of! The first time a major refactoring is required – the light bulb turns on AUHenrik Bærbak Christensen15

Iteration 2 Betatown Rate Policy

Triangulation at Algorithm Level Introducing the real BetaTown rate policy is a nice example of using Triangulation –Iteration 2 Add test case for first hour => production code –Iteration 3: Add test case for second hour Add just enough complexity to the rate policy algorithm –Iteration 4: Add test case for third (and following) hour Add just enough more complexity AUHenrik Bærbak Christensen17

Iteration 5 Unit and IntegrationTesting

Separate Testing I can actually test the new rate policy without using the pay station at all AUHenrik Bærbak Christensen19

Advantages The unit testing of the progressive rate strategy is much simpler than the corresponding test case, using the strategy integrated into the pay station. AUHenrik Bærbak Christensen20 Compare

Testing Types Now –I test the ProgressiveRateStrategy in isolation of the pay station (Unit testing) –The pay station is tested integrated with the LinearRateStrategy (Integration testing) Thus the two rate strategies are tested by two approaches –In isolation (unit) –As part of another unit And –The actual Betatown pay station is never tested! AUHenrik Bærbak Christensen21

Definitions Experience tells us that testing the parts does not mean that the whole is tested! –Often defects are caused by interactions between units for wrong configuration of units! AUHenrik Bærbak Christensen22

Exercise Tricky – but –Give me a concrete example where having tested all the units in isolation does not guaranty that the system works correctly! –The Mars Climate Orbiter... AUHenrik Bærbak Christensen23

Integration Testing the Pay Station I must add a testcase that validate that the AlphaTown and BetaTown products are correctly configured! AUHenrik Bærbak Christensen24

More advanced integration testing The pay station case’s integration is pretty simple as it is all a single process application. Net4Care case –Maven integration testing involves starting web server and running tests against it to validate realistic deployment. AUHenrik Bærbak Christensen25

And system testing Karibu case –(Manual) system test requires Two servers running clustered RabbitMQ Two servers running Karibu Daemons Three servers running replica set Mongo databases –Test cases include Shutting down servers and validate data keeps flowing and reviewing log messages for proper handling of shut down events... AUHenrik Bærbak Christensen26

Iteration 6: Unit Testing Pay Station

Separate Testing I can actually also apply Evident Test to the testing of the pay station by introducing a very simple rate policy AUHenrik Bærbak Christensen28

Resulting test cases Using this rate policy makes reading pay station test cases much easier! AUHenrik Bærbak Christensen29

Outlook System Testing

Testing levels The normal classification is –Unit testing: Individual software units –Integration testing: unit collaborations –System testing: User requirements In our simple pay station, system testing is actually equal to the unit test of interface PayStation. –In TDD all units tests pass all the time after an interation!!! –System tests do not, but moves towards 100% as the product emerges over many iterations. AUHenrik Bærbak Christensen31

32 XP and TDD Traditional Testing Terminology –Unit testing, Integration Testing, System Testing TDD: –Unit tests Owned by developers Automatic Runs 100% all the time! –Functional tests Owned by costumers Automatic Comprehensive and timely Public, to show progress AUHenrik Bærbak Christensen

Conclusion

Advice Do not code in anticipation of need, code when need arise... Automatic tests allow you to react when need arise –because you dare refactor your current architecture... AUHenrik Bærbak Christensen34

Refactoring When ’architecture refactoring’ need arise then A) Use the old functional tests to refactor the architecture without adding new or changing existing behaviour B) When everything is green again then proceed to introduce new/modified behaviour C) Review again to see if there is any dead code lying around or other refactorings to do. AUHenrik Bærbak Christensen35

Discussion These refactorings shown here are very local, so the ‘architecture decisions’ are also local. However sometimes you need to make larger architectural changes that invalidate the test cases  –Changing API or the way units are used –Ex: Changing persistence from file to RDB based What to do in this case? AUHenrik Bærbak Christensen36