Upload
clemence-weaver
View
213
Download
0
Embed Size (px)
Citation preview
Testing in Extreme Programming
By Mong-Hang Vo
CS 240 Software ProjectMaster of Science in Computer
ScienceSan Jose State University
December 03, 2003Professor Badrul Sarwar
Agenda
Testing in XP Overview JUnit Framework
Rules and Practices of XP Planning Designing Coding
Code the unit tests first Testing
Coding The Unit Tests First Create one test to define some small
aspect of the problem Then create the simplest code that will
make that test pass Then create a second test Add to the code you just created to make
this new test pass … Continue until there is nothing left to
test.
Coding The Unit Tests First Give a better idea of what features
need to be in a class Immediate feedback Easier and faster to create your
code No need to create them after the
code Save you a lot of time.
Testing in XP Unit Tests Acceptance Tests.
Testing in XP All code must have unit tests All code must pass unit tests
before it can released When a bug is found tests are
created Acceptance tests are run often and
the score is published.
Unit Tests Majority of the testing in XP is unit
testing Unit tests XP style
Download a unit test framework to be able to create automated unit tests suites
Test all classes in the system Create your tests first before coding
Unit tests are released into the code repository along with the code they test.
Unit tests
Enable Collective Code Ownership Enable refactoring.
Collective Code Ownership Everyone in the development team
owns all the code When a change is required, any
programmer can make the change at any time
More reliable than putting a single person in charge of specific classes.
Refactoring Removing redundant and unused
code Keep the design simple.
Acceptance Tests
Created from user stories provided by the customers
Are black box system tests Should be automated so it can be
run often The implementation and running of
acceptance tests can be done by the Software QA team.
Quality assurance (QA) An essential part of the XP process Can be done by a separate group Can be integrated into the
development team XP requires development to have
much closer relationship with QA
Unit Tests Framework Download
www. XProgramming.com JUnit Framework
http://www.junit.org Developed by Luckily Erich Gamma
and Kent Beck The standard for unit testing in Java.
JUnit Framework A set of classes that allows you to
easily create and run a set of unit tests.
Run unit tests Command line mode JUnit GUI
A test case is usually implemented as a subclass of junit.framework.TestCase
JUnit Framework The execution of a test method in
JUnit follows the model: setUp(); test<method_name>(); tearDown();
Junit distinguishes errors from failures. Failures are anticipated by the assert methods.
These methods compare actual result with expected results.
JUnit Framework If a test fails, execution of the current
test method is aborted. A test case repeats the above model,
using reflection to find all test methods.
Test methods must be public, void, take no arguments, and have a name that starts with "test" (so that reflection can determine which methods to call).
JUnit Framework
JUnit Framework
JUnit Framework Automate unit testing of Java
classes Test code should be documented
with Javadocs. Easier to maintain well-documented
test cases Is an easy-to-use framework.
References http://www.extremeprogramming.org Unit tests Samples in JUnit installation Unit Testing: Test Early, Test Often by
Michael Olan Test first, code later: a guide to
integrating JUnit into development process by Thomas Hammell and Robert Nettleton (sjlibray.org)
Thank You!