22
Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003 Professor Badrul Sarwar

Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

Embed Size (px)

Citation preview

Page 1: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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

Page 2: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

Agenda

Testing in XP Overview JUnit Framework

Page 3: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

Rules and Practices of XP Planning Designing Coding

Code the unit tests first Testing

Page 4: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 5: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 6: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

Testing in XP Unit Tests Acceptance Tests.

Page 7: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 8: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 9: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

Unit tests

Enable Collective Code Ownership Enable refactoring.

Page 10: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 11: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

Refactoring Removing redundant and unused

code Keep the design simple.

Page 12: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 13: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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

Page 14: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 15: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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

Page 16: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 17: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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).

Page 18: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

JUnit Framework

Page 19: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

JUnit Framework

Page 20: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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.

Page 21: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

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)

Page 22: Testing in Extreme Programming By Mong-Hang Vo CS 240 Software Project Master of Science in Computer Science San Jose State University December 03, 2003

Thank You!