42
Comparative Development Methodologies Lecture 7 XP (Tools) For the BSc IS&M Programme Dell Zhang Birkbeck, University of London

Comparative Development Methodologies

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Comparative Development Methodologies

Comparative Development Methodologies

Lecture 7

XP (Tools)

For the BSc IS&M Programme

Dell ZhangBirkbeck, University of London

Page 2: Comparative Development Methodologies

From Teach Yourself Extreme Programming In 24 Hours.

Page 3: Comparative Development Methodologies

Something New

Version Control Subversion (http://subversion.tigris.org/)

TortoiseSVN (http://tortoisesvn.tigris.org/) Git (http://git.or.cz/)

Testing xUnit, e.g., JUnit (http://www.junit.org/): client Cactus (http://jakarta.apache.org/cactus/): server

Page 4: Comparative Development Methodologies

Something New

Automated Build & Project Management Apache Ant (http://ant.apache.org/) Apache Maven (http://maven.apache.org/)

Bug-Tracking & Project Management Trac (http://trac.edgewall.org/)

Page 5: Comparative Development Methodologies

Something New

Code Generation XDoclet (http://xdoclet.sourceforge.net/)

Collaboration Wiki (http://en.wikipedia.org/wiki/Wiki)

Development Environment Eclipse (http://www.eclipse.org/ ) jEdit (http://www.jedit.org/)

Page 6: Comparative Development Methodologies

Version Control

Do you work in a team? Has it ever happened that you were working on a file,

and someone else was working on the same file at the same time? Did you lose your changes to that file because of that?

Have you ever saved a file, and then wanted to revert the changes you made? Have you ever wished you could see what a file looked like some time ago?

Have you ever found a bug in your project and wanted to know when that bug got into your files?

Page 7: Comparative Development Methodologies

Version Control

Page 8: Comparative Development Methodologies
Page 9: Comparative Development Methodologies
Page 10: Comparative Development Methodologies
Page 11: Comparative Development Methodologies
Page 12: Comparative Development Methodologies
Page 13: Comparative Development Methodologies
Page 14: Comparative Development Methodologies

Features Directory versioning Atomic commits Versioned metadata Choice of network layers Consistent data handling Efficient branching and tagging Hackability

Page 15: Comparative Development Methodologies
Page 16: Comparative Development Methodologies
Page 17: Comparative Development Methodologies
Page 18: Comparative Development Methodologies

xUnit

The xUnit testing framework is a simple, easy-to-use unit testing tool.

There are many versions of the framework, depending on language. JUnit for Java, CppUnit for C++ PyUnit for Python VBUnit for Visual Basic ……

Page 19: Comparative Development Methodologies

Recall: Test Driven Development If it's worth building, it's worth testing.

TDD lifecycle

Page 20: Comparative Development Methodologies

JUnit

Architecture

Page 21: Comparative Development Methodologies

JUnit

Packages import org.junit.Test import static org.junit.Assert.* ……

Page 22: Comparative Development Methodologies

JUnit

Simple Test Case Annotate a method with @Test Check values with assertions

assertEquals assertTrue; assertFalse assertSame; assertNotSame assertNull; assertNotNull fail; …

http://junit.sourceforge.net/javadoc/junit/framework/Assert.html

Page 23: Comparative Development Methodologies
Page 24: Comparative Development Methodologies

JUnit

Fixture Tests need to run against the background of a

known set of objects which is called a test fixture. Often, you will be able to use the same fixture for

several different tests. Each case will send slightly different messages or

parameters to the fixture and will check for different results.

Page 25: Comparative Development Methodologies

JUnit

Initialization/Releasing for Common Fixture Run before and after each test

@Before @After

Run before and after all tests @BeforeClass @AfterClass

Page 26: Comparative Development Methodologies

JUnit

New Testing Methods in JUnit4 Test for exceptions

@Test(expected = Exception.class) Test for performance

@Test(timeout = 500)

Page 27: Comparative Development Methodologies
Page 28: Comparative Development Methodologies

JUnit

Test Runners The test runner will use reflection to ascertain test

names at runtime, and then execute your tests. JUnit4 only comes with a textual TestRunner.

org.junit.runner.TextListener.run(TestClass1.class, ...);  For graphical interface,

Use an IDE that supports JUnit4.

Page 29: Comparative Development Methodologies

JUnit Plugin for Eclipse

Page 30: Comparative Development Methodologies

JUnit

Failure vs. Errors Failures are anticipated and checked for with

assertions. Errors are unanticipated problems.

Page 31: Comparative Development Methodologies

Ant

Ant is an automated build tool Java-based Open Source An Apache project Driven by an XML format build file Like make, but without make's wrinkles Comes with Eclipse

Page 32: Comparative Development Methodologies

Ant

Build Process Get latest source code Clean target folders Create new target folders Compile and link source Run unit tests Deploy to staging

Page 33: Comparative Development Methodologies

Ant

Build File – Layout

Page 34: Comparative Development Methodologies

Ant

Build File – Tags Project

The top-level tag in the build file that describes the project itself.

Target A target defines a collection of Ant tasks. A target can depend on other targets. A target also has the capability to perform its execution if

(or unless) a property has been set.

Page 35: Comparative Development Methodologies

Ant

Build File – Tags Task

A task is a piece of code that can be executed. A task can have multiple attributes or arguments.

The value of an attribute might contain references to a property.

These references will be resolved before the task is executed.

There is a set of built-in tasks, along with a number of optional tasks; it's also very easy to write your own.

Page 36: Comparative Development Methodologies

Ant

Build File – Tags Task (

http://ant.apache.org/manual/tasksoverview.html) Archive; Audit/Coverage; Compile; Deployment;

Documentation; EJB; Execution; File; Java2 Extensions; Logging; Mail; Miscellaneous; .NET; Pre-process; Property; Remote; SCM; Testing; Visual Age for Java …

Page 37: Comparative Development Methodologies

Ant

Build File – Tags Property

A project can have a set of properties. A property has a name and a value. Properties can be used in the value of tag attributes.

This is done by placing the property name between "${" and "}" in the attribute value, e.g. ${builddir}.

In addition to properties defined in the build file, Ant also provides access to all system properties and some built-in properties.

Page 38: Comparative Development Methodologies

Ant

Build File – Example

Page 39: Comparative Development Methodologies

Ant

Page 40: Comparative Development Methodologies

Ant

Integrating Unit Tests and Build Setting up the Test Data with Ant

Ant can be used to directly execute SQL commands onto any database that supports ODBC (via JDBC).

Running JUnit Tests from Ant Using Ant to Email Test Reports

Page 41: Comparative Development Methodologies
Page 42: Comparative Development Methodologies

Take Home Messages

Subversion Version Control Tool http://subversion.tigris.org/

JUnit Unit Testing Tool http://www.junit.org/

Ant Automated Build Tool (and Much More) http://ant.apache.org/