xtreme Programming (summary of Kent Beck s XP book) Stefan Resmerita, WS2015

Similar documents
Introduction to Extreme Programming. Extreme Programming is... Benefits. References: William Wake, Capital One Steve Metsker, Capital One Kent Beck

Practical Objects: Test Driven Software Development using JUnit

Introduction to Extreme Programming

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

Wolfgang Pree Software Research Lab Univ. of Constance Germany

Object Oriented Software Design - I

Testing Stragegies. Black Box Testing. Test case

EECS 4313 Software Engineering Testing

E xtr B e y CS R m oy 6704, e T a P n a Spring r n o d J g ia n 2002 r g a S m hu m ing

Tuesday, November 15. Testing

Test automation / JUnit. Building automatically repeatable test suites

Test automation Test automation / JUnit

2. Reasons for implementing clos-unit

Test-Driven Development JUnit

JUnit A Cook's Tour. Kent Beck and Erich Gamma. Renaat Verbruggen 1#

Test automation / JUnit. Building automatically repeatable test suites

Software Development Process Models

Test-Driven Development JUnit

Agile Development

Chapter 14 Software Testing Techniques

JUnit in EDA Introduction. 2 JUnit 4.3

Lecture 17: Case Study: JUnit

Agile Software Development. Lecture 7: Software Testing

Java Review via Test Driven Development

4. A Testing Framework

Unit Testing with JUnit and CppUnit

XP: Planning, coding and testing. Practice Planning game. Release Planning. User stories. Annika Silvervarg

JUnit: The Goals of JUnit

Testing. CMSC 433 Programming Language Technologies and Paradigms Spring A Real Testing Example. Example (Black Box)?

Introduction to. and. Scott W. Ambler Source Documents

Lecture 3. Black- box Tes3ng

XP: Planning, coding and testing. Planning. Release planning. Release Planning. User stories. Release planning Step 1.

TEST-DRIVEN DEVELOPMENT

JUnit Test Patterns in Rational XDE

4. A Testing Framework. Oscar Nierstrasz

The Power of Unit Testing and it s impact on your business. Ashish Kumar Vice President, Engineering

Functional Testing (Testování funkčnosti)

Reengineering II. Transforming the System

Tutorials for Struts, EJB, xdoclet and eclipse.

Software Engineering I (02161)

8. Quality Assurance

Agenda. JUnit JaCoCo Project. CSE 4321, Jeff Lei, UTA

TestCenter User Manual. User Manual. v

COMP6471 WINTER User-Centered Design

Junit Overview. By Ana I. Duncan

1: Introduction to Object (1)

How Can a Tester Cope With the Fast Paced Iterative/Incremental Process?

Analysis of the Test Driven Development by Example

Agile Manifesto & XP. Topics. Rapid software development. Agile methods. Chapter ) What is Agile trying to do?

Test suites Obviously you have to test your code to get it working in the first place You can do ad hoc testing (testing whatever occurs to you at

The Need for Agile Project Management

defined. defined. defined. defined. defined. defined. defined. defined. defined.

JUnit Framework. Terminology: assertions, annotations, fixtures. Dr. Siobhán Drohan Mairead Meagher. Produced by:

Unit testing in CakePHP. Making bullet resistant code.

Test Driven Development TDD

linaye/gl.html

Testing. Technion Institute of Technology Author: Assaf Israel. Author: Assaf Israel - Technion

Review sheet for Final Exam (List of objectives for this course)

Making the case for SD-WAN

Dealing with Bugs. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 27 04/21/2009

Minding The Store, Autodesk Revit for Retail Users

Automated Acceptance Testing

SWE 434 Software Testing and Validation

Analysiss of Software Artifacts

Creating an Intranet using Lotus Web Content Management. Part 2 Project Planning

Extreme programming XP 6

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle

Testing. Topics. Types of Testing. Types of Testing

Tools for Unit Test - JUnit

Tools for Unit Test JUnit

QUIZ. What is wrong with this code that uses default arguments?

print statements, debugger expressions, test scripts. Writing expressions in a debugger only that t a program works now. An application typically

Software Design and Analysis CSCI 2040

Testing in Agile Software Development

Review: Cohesion and Coupling, Mutable, Inheritance Screen Layouts. Object-Oriented Design CRC Cards - UML class diagrams

Advanced Software Testing Testing Code with Static Analysis

Activities Common to Software Projects. Software Life Cycle. Activities Common to Software Projects. Activities Common to Software Projects

JUnit 4 and Java EE 5 Better Testing by Design

Check out FilesAndExceptions from SVN. Exam 2 Review File I/O, Exceptions Vector Graphics Project

a. The following method would allow an object of the static type List<String> to be passed to it as an argument.

How Can Testing Teams Play a Key Role in DevOps Adoption?

The most frequently asked questions about JUnit are answered here (especially sections 4, 5 and 7):

White-box testing. Software Reliability and Testing - Barbara Russo SERG - Laboratory of Empirical Software Engineering.

Capturing JUnit Behavior into Static Programs

Chapter 9 Quality and Change Management

Software Engineering I (02161)

Adopting Agile Practices

Pearson Education 2007 Chapter 9 (RASD 3/e)

Chapter 3. Unit Testing with JUnit and Debugging. Testing with JUnit getting started. Note

Automation Using Selenium or Web Driver and Unit Testing

TEST DRIVEN DEVELOPMENT

Software Engineering and Scientific Computing

Verifying and Documenting ADTs: Javadoc, Java Assertions and JUnits

Think like an Elm developer

Design Stories Exploring and Creating Code from a Narrative Perspective Kevlin

Credit where Credit is Due. Lecture 25: Refactoring. Goals for this lecture. Last Lecture

Kanban & Making Your Production Scream

Mobile Test Automation is not Rocket Science! Baris

Testing and Migration

Experience-based Refactoring for Goal- oriented Software Quality Improvement

Transcription:

xtreme Programming (summary of Kent Beck s XP book) 1

Contents The software development problem The XP solution The JUnit testing framework 2

The Software Development Problem 3

Risk Examples delivery schedule project cancelled high defect rate - system unusable business misunderstood or changed false feature rich staff turnover 4

Four control variables in SW development Cost Time Quality Scope External forces (customers, management) pick the values of any three of the variables Development team picks the value of the fourth variable Make the four variables visible 5

Interaction between the variables Cost: more money can help a little Too much money creates more problems than it solves Time: more time can improve quality and increase scope too much time will hurt it Quality: short-term gains by deliberately sacrificing quality but the cost (human, business, technical) is enormous less scope => better quality (as long as the business problem is still solved) 6

The four values of XP Communication Simplicity Feedback Courage 7

Short-term vs. long term thinking (I) Communication: effect of pair programming, unit testing, task estimation programmers, customers and managers have to communicate Monitored by a coach Simplicity: it is better to do a simple thing today and pay a little more tomorrow to change it, than to do a more complicated thing today that may never be used anyway 8

Short-term vs. long term thinking (II) Feedback: when customers write new stories (description of features, simplified use cases): the programmers immediately estimate them; customers and testers write functional tests for all the stories must be enabled by putting the system in production as early as possible Courage: throwing parts of the code away and start over on the most promising design 9

Basic principles (derived from the four values) Rapid feedback Assume simplicity Incremental change Embracing change Quality work 10

Some more principles small initial investment play to win concrete experiments open, honest communication work with people s instincts, not against them 11

Basic activities in the XP development process Coding Testing Listening Designing 12

The Solution 13

The solution: overview Practices Management strategy Planning strategy 14

XP Practices (I) Planning game: determine the scope of the next release; as reality overtakes the plan, update the plan Small releases: release new versions on a very short cycle after putting a simple system into production quickly Metaphor: guide development with a simple shared story of how the whole system works 15

XP Practices (II) Simple design: as simple as possible but not simpler (A. Einstein) Testing: continually write unit tests Refactoring: restructure the system to remove duplication (c.f. framelets, etc.) Pair programming: two programmers at one machine Collective ownership 16

XP Practices (III) Continuous integration: integrate the system many times a day, every time a task is complete 40-hour week On-site customer: include a real, live customer Coding standards 17

Practices support each other 18

Management Strategy: Overview decentralized decision making, based on metrics coaching tracking intervention using business basics: phased delivery, quick and concrete feedback, clear articulation of the business needs 19

Metrics don t have too many metrics numbers are regarded as a way of gently and noncoercively communicating the need for change ratio between the estimated development time and calendar time is the basic measure for running the Planning Game 20

Coaching be available as a development partner see long-term refactoring goals explain the process to upper-level management no lead programmer, system architect, etc. Get everybody else to make good decisions 21

Tracking It is the job of the tracker to gather whatever metrics are being tracked at the moment and make sure the team is aware of what was actually measured (and reminded of what was predicted or desired). Running the Planning Game is a part of tracking. The tracker needs to know the rules of the game and be prepared to enforce them 22

Intervention when problems cannot be solved by the emergent brilliance of the team, the manager has to step in, make decisions and see the consequences through to the end sample situations: changing the team s process, personnel changes, quitting a project 23

Planning Strategy: Overview bring the team together decide on scope and priorities estimate cost and schedule give everyone confidence that the system can be done provide a benchmark for feedback put the most valuable functionality into production asap 24

XP Summary 25

What makes XP hard? It s hard to... do simple things admit you don t know (eg, basics about computer/ software science in the context of pair programming) collaborate break down emotional walls 26

XP & Kent Beck (I) Kent Beck is afraid of: doing work that doesn t matter having projects canceled making business decisions badly doing work without being proud of it 27

XP & Kent Beck (II) Kent Beck is not afraid of: coding changing his mind proceeding without knowing everything about the future relying on other people changing the analysis and design of a running system writing tests 28

Testing: the JUnit 3.x framework (with UML-F diagrams) 29

The JUnit components (I) Adding new test cases: JUnit provides a standard interface for defining test cases and allows the reuse of common code among related test cases. Tests suites: Framework users can group test cases in test suites. Reporting test results: the framework keeps flexible how test results are reported. The possibilities include storing the results of the tests in a database for project control purposes, creating HTML files that report the test activities. 30

The JUnit components (II) Overview of JUnit design For example, class ComplexTest defines test cases for complex numbers 31

The TestCase variation point (I) The TestCase design is based on the Template Method design pattern The method run() controls the test execution 32

The TestCase variation point (II) The initialization part is responsible for creating the test fixture. The test itself uses the objects created by the initialization part and performs the actions required for the test. Finally, the third part cleans up a test. 33

The TestSuite variation point TestCases are grouped into TestSuites variation of the Composite design pattern Black-box adaptation 34

The TestResult variation point (I) Failures are situations where the assert() method does not yield the expected result. Errors come from unexpected bugs in the code being tested or in the test cases themselves. The TestResult class is responsible for reporting the failures and errors in different ways. 35

The TestResult variation point (II) TestResult must provide four methods: starttest() - initialization code addfailure() - reports a failure adderror() - reports an error endtest() - clean-up code 36

The TestResult variation point (III) 37

Adapting JUnit Cookbook recipes and UML-F diagrams for each of the JUnit variation points Create a test case (ComplexTest) Create a test suite (for the ComplexTest methods) Create an HTML reporting mechanism 38

Adapting TestCase (I) TestCase adaptation recipe: Subclass TestCase Override setup() (optional). The default implementation is empty Override runtest() Override teardown() (optional). The default implementation is empty 39

Adapting TestCase (II) TestCaseExample illustrates the code that has to be added by the application developer White-box adaptation 40

Adapting TestCase (III) Four possible adaptation examples, considering the optional hook methods 41

Adapting TestCase (IV) One aspect in the TestCase class cannot be captured in UML-F design diagrams Method runtest() takes no parameters as input Different test cases require different input parameters The interface for theses test methods has to be adapted to match runtest() 42

Adapting TestCase (V) 43

Adapting TestCase (VI) 44

Adapting TestSuite (I) 45

Adapting TestSuite (II) TestCase and TestSuite are related variation points public static Test suite() { TestSuite suite = new TestSuite(); suite.addtest(new ComplexTest("testing add") { } ); protected void runtest() { this.testadd(); } suite.addtest(new ComplexTest("testing multiply") { } ); protected void runtest() { this.testmultiply(); } } return suite; 46

Adapting TestResult 47

Pattern-annotated diagrams Pattern-annotated diagram for the main JUnit classes 48

From JUnit 3.x to JUnit 4.x (an annotation-based framework) 49

Simplified usage through annotations JUnit 4 requires Java 5 or newer No TestCase class Use an ordinary class for a test case (don t extend TestCase) Use annotations instead of special method names: Instead of a setup method, put @Before before some method Instead of a teardown method, put @After before some method You can define multiple test methods with any names, just put @Test before each test method Useful assertion methods are defined in the static-only class Assert 50

Java annotations in a nutshell From J2SE 5 up Allow adding decorations to code (resemble Java tags, e.g., @author) Used for code documentation, compiler processing, code generation, runtime processing Small set of predefined annotations (e.g., @Deprecated) New annotations can be created by developers 51

The ComplexTest Example in Junit 4.x import org.junit.*; import static org.junit.assert.*; public class ComplexTest { private ComplexNumber fzeroone; private ComplexNumber fminusonezero; private ComplexNumber foneone; @Before public void setup() { } fzeroone = new ComplexNumber(0, 1); fminusonezero = new ComplexNumber(-1, 0); foneone = new ComplexNumber(1, 1); } @Test public void testadd() { //This test will fail!!! ComplexNumber result = foneone.add(fzeroone); asserttrue(foneone.equals(result)); } @Test public void testmultiply() { ComplexNumber result = fzeroone.multiply(fzeroone) asserttrue(fminusonezero.equals(result)); } 52

Before and After @BeforeClass: one-time initialization, when the class is loaded @AfterClass: clean-up method, after all tests have been completed Multiple @Before and @After methods possible, no order assumed for example: @Before public void setupzeroone() { fzeroone = new ComplexNumber(0, 1); } @Before public void setupminusonezero() {fminusonezero = new ComplexNumber(-1, 0);} @Before public void setuponeone() { foneone = new ComplexNumber(1, 1); } 53

Additional features Execution time limit to avoid infinite loops @Test (timeout = 10) Specification of expected exceptions @Test (expected = ArrayIndexOutOfBoundsException.class) Parameterized tests: A series of tests which differ only in the inputs and expected results can be written as a single test by providing: A static method that generates and returns a list of data items A single constructor that stores one data item to test A test method 54

Example of parameterized test @RunWith(Parameterized.class) public class ComplexTestParam { private ComplexNumber fzeroone; private ComplexNumber expectedresult; private ComplexNumber secondterm; } public ComplexTestParam(ComplexNumber expected, ComplexNumber secondterm) { this.expectedresult = expected; this.secondterm = secondterm; fzeroone = new ComplexNumber(0, 1); } @Parameters public static Collection<Object[]> generateinputs() { return Arrays.asList(new Object[][]{ {new ComplexNumber(-1,0), new ComplexNumber(0,1)}, {new ComplexNumber(1,0), new ComplexNumber(1,0)} //wrong }); } @Test public void testmultiply() { ComplexNumber result = fzeroone.multiply(secondterm) asserttrue(result.equals(expectedresult)); } 55

Test suites in Junit 4.x A test suite is defined by an annotation to some (possibly empty) class Example: @RunWith(Suite.class) @Suite.SuiteClasses( { ComplexTest.class, ComplexTestParam.class }) public class AllComplexTests { //empty } // Complete source code available online (see course homepage) 56