Test Driven Lasse Koskela Chapter 3: Refactoring in Small Steps

Slides:



Advertisements
Similar presentations
Introduction to Software Testing Chapter 1
Advertisements

Introduction to Software Testing Chapter 3.3 Logic Coverage for Source Code Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 1 Paul Ammann & Jeff Offutt SUMMARY OF PARTS 1 AND 2 FROM LAST WEEK.
BUSINESS DRIVEN TECHNOLOGY
Introduction to Software Testing Chapter 9.2 Challenges in Testing Software – Software Testability Paul Ammann & Jeff Offutt
Object Oriented Programming
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
TDD Example Test Driven – Koskela Chapter 2. Mail Template Test List 1.Evaluating template “Hello, ${name}” with the value “Reader” for variable “name”
Introduction to Software Testing Chapter 3.1 Logic Coverage Paul Ammann & Jeff Offutt.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Chapter 8 Systems of Linear Equations in Two Variables Section 8.3.
Coming up: What is Agile? XP Development Dan Fleck 2010 Dan Fleck 2010.
Refactoring Presentation Yash Pant. Overview 3 Refactoring Types: 1. Replace Error Code with Exception 2. Split Temporary Variable 3. Remove Middle Man.
Chapter 5 Agile Development Moonzoo Kim KAIST
Paul Ammann & Jeff Offutt
Chapter 12 Section 1.
CSC 221: Computer Programming I Spring 2010
Introduction to JUnit CS 4501 / 6501 Software Testing
Unit testing Java programs Using JUnit
Project Learning in Capstone Design
Paul Ammann & Jeff Offutt
CSC 221: Computer Programming I Fall 2005
TDD Overview CS 4501/6501 Software Testing
Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage
Welcome to SWE 637 Software Testing Jeff Offutt.
Un</br>able’s MySecretSecrets
Paul Ammann & Jeff Offutt
Design and Implementation of Software for the Web
(Test Driven) Software Development
Test Driven Lasse Koskela Chapter 2: Beginning TDD
Paul Ammann & Jeff Offutt
Chapter 0 The Course Plan.
Chapter 0 The Course Plan.
Software Testing and Maintenance Modifying Code
Paul Ammann & Jeff Offutt
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
Software Testing and Maintenance Maintenance and Evolution Overview
Introduction to JUnit CS 4501 / 6501 Software Testing
Introduction to Software Testing (2nd edition) Chapter 4 TDD Example
Paul Ammann & Jeff Offutt
Chapter 4 Loops While loop The for loop do… while break and continue
Test Driven Lasse Koskela Chapter 2: Beginning TDD
Jeff Offutt SWE 637 Software Testing
Text Analyzer BIS1523 – Lecture 14.
Software Maintenance and Design
Software Usability Analysis and Design
Objects First with Java A Practical Introduction using BlueJ
Developer Productivity: What’s New in C# 6
Self Directed Search SDS.
Coming up: What is Agile?
Review for Midterm Spring 2018
The Challenge of Cross - Language Interoperability
Portfolio project Reflection
Objects First with Java A Practical Introduction using BlueJ
Chapter 1 Jeff Offutt Chapter 1.1, Concept 1 The 7  2 rule.
Norman Chapter 1 Psychopathology
Krug Chapter 3 Billboard Design 101
Norman Chapter 6 Krug Chapter 7 D: Undo
Krug Chapter 5 Omit Needless Words
Krug Chapter 2 How We Really Use the Web and Web Site Design
Paul Ammann & Jeff Offutt
Levels of Learning A gross simplification of Bloom’s taxonomy
Krug Chapter 12 Accessibility
Krug Chapter 6 Street signs and Breadcrumbs
Software Usability and Design
Software Usability and Design
Krug 4 Animal, Mineral, or Vegetable
Career Goal setting By Elise Vogelman Elise Vogelman.
Test Driven Lasse Koskela Chapter 3: Refactoring in Small Steps
Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage
Presentation transcript:

Test Driven Lasse Koskela Chapter 3: Refactoring in Small Steps Paul Ammann & Jeff Offutt SWE 437 George Mason University 2018

Overview Exploring a potential solution Changing design in a controlled manner Taking the new design further Most powerful designs are always the result of a continuous process of simplification and refinement SWE 437- Software Testing and Maintenance © Ammann & Offutt

What Is a Spike? A detour to learn something new Package, details of an API, etc. Whether a proposed design will work Spikes are experimental in nature Self education—increase knowledge, skills, or abilities SWE 437- Software Testing and Maintenance © Ammann & Offutt

The Problem from Chapter 2 Existing design replaced variables via simple matching For all variables v, replace ${v} with its value: result = result.replaceAll (regex, entry.getValue()) Failing test: Sets the value to “${one}, ${two}, ${three}” @Test public void variablesGetProcessedJustOnce() throws Exception { template.set (“one”, “${one}”); template.set (“two”, “${three}”); template.set (“three”, “${two}”); assertTemplateEvaluatesTo (“${one}, ${three}”, ${two}); } regexp blows up Tweaking the current design won’t make this test pass SWE 437- Software Testing and Maintenance © Ammann & Offutt

Exploring A Potential Solution Break the templates into “segments” Prototyping with spikes A spike is a detour to learn In the template example, we learn more about using regex Learn by writing tests (learning tests) Need to figure out an API? Write some tests that use the API RegexLearningTest on Ammann’s website, from section 3.3 Example spike for learning an API Note that Koskela thought find() would count occurrences He learned it breaks strings into pieces Learn on a short detour, then apply SWE 437- Software Testing and Maintenance © Ammann & Offutt

Core Idea Use regexp to break the following string : Into the following 5 pieces : Now the variables can easily be identified and replaced regexp will not explode if values have `$’, `{’, or `}’ “${greeting} ${fname}, Thank you for your interest in ${product}.” “${greeting}” “${fname}” “, Thank you for your interest in ” “${product}” “.” SWE 437- Software Testing and Maintenance © Ammann & Offutt

Changing Design in a Controlled Way Chapter 3 has a lot of details that you should study on your own I suggest going through the exercise with his code and eclipse No new functionality, but completely refactored Template.java Segment, PlainText, Variable SWE 437- Software Testing and Maintenance © Ammann & Offutt