Presentation is loading. Please wait.

Presentation is loading. Please wait.

Testing in Extreme Programming

Similar presentations


Presentation on theme: "Testing in Extreme Programming"— Presentation transcript:

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 Professor Badrul Sarwar

2 Agenda Testing in XP Overview JUnit Framework

3 Rules and Practices of XP
Planning Designing Coding Code the unit tests first Testing

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

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

6 Testing in XP Unit Tests Acceptance Tests.

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

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

9 Unit tests Enable Collective Code Ownership Enable refactoring.

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

11 Refactoring Removing redundant and unused code Keep the design simple.

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

13 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

14 Unit Tests Framework Download JUnit Framework www. XProgramming.com
Developed by Luckily Erich Gamma and Kent Beck The standard for unit testing in Java.

15 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

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

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

18 JUnit Framework

19 JUnit Framework

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

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

22 Thank You!


Download ppt "Testing in Extreme Programming"

Similar presentations


Ads by Google