Post on 29-Nov-2014
description
Comparative Development Methodologies
Lecture 7
XP (Tools)
For the BSc IS&M Programme
Dell ZhangBirkbeck, University of London
From Teach Yourself Extreme Programming In 24 Hours.
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
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/)
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/)
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?
Version Control
Features Directory versioning Atomic commits Versioned metadata Choice of network layers Consistent data handling Efficient branching and tagging Hackability
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 ……
Recall: Test Driven Development If it's worth building, it's worth testing.
TDD lifecycle
JUnit
Architecture
JUnit
Packages import org.junit.Test import static org.junit.Assert.* ……
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
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.
JUnit
Initialization/Releasing for Common Fixture Run before and after each test
@Before @After
Run before and after all tests @BeforeClass @AfterClass
JUnit
New Testing Methods in JUnit4 Test for exceptions
@Test(expected = Exception.class) Test for performance
@Test(timeout = 500)
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.
JUnit Plugin for Eclipse
JUnit
Failure vs. Errors Failures are anticipated and checked for with
assertions. Errors are unanticipated problems.
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
Ant
Build Process Get latest source code Clean target folders Create new target folders Compile and link source Run unit tests Deploy to staging
Ant
Build File – Layout
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.
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.
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 …
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.
Ant
Build File – Example
Ant
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
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/