Program Testing - PowerPoint PPT Presentation

1 / 45
About This Presentation
Title:

Program Testing

Description:

York Region District School Board. November 13, 2004. ACSE Conference ... A simple project that will allow us to book appointments during a weekday of 9-5. ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 46
Provided by: ela9
Category:
Tags: program | testing

less

Transcript and Presenter's Notes

Title: Program Testing


1
Program Testing
  • Eileen Landa
  • York Region District School Board

2
Purpose
  • To look at why testing is so important
  • To look at current industry thinking about
    programming and testing
  • To look at methods to improve student ability to
    test
  • To look at a specific testing option available
    for Java programming

3
Agenda
  • Extreme Programming
  • Black box vs white box testing Industry
    standards
  • Ministry expectations on testing
  • Making testing fun (numtowords example)
  • Tools for testing
  • BlueJ individual class testing
  • BlueJ unit testing record and capture

4
Extreme Programming
  • A deliberate and disciplined approach to software
    development
  • Stress is on customer satisfaction
  • Emphasizes team work
  • Improves a software project in
  • Communication
  • Simplicity
  • Feedback
  • Courage
  • Like a jigsaw puzzle

5
A Change in the Way We Program
  • Software engineered to be simple and elegant
  • Savings in programmer costs outweigh savings in
    hardware cost by factor of at least 10 times
  • XP emphasizes not just testing but testing well
  • XP programmers do not mind changing requirements

6
Rules and Practises
  • Four phases
  • Planning
  • Designing
  • Coding
  • Testing

7
Planning
  • User stories written
  • Release planning creates schedule
  • Frequent small releases
  • Project velocity is measured
  • Project divided into iterations
  • Iteration planning starts each iteration
  • People move around
  • Stand-up meeting starts each day
  • Fix XP when it breaks

8
Designing
  • Simplicity
  • System metaphor
  • Use CRC cards
  • Create spike solutions
  • No functionality is added early
  • Refactor

9
Coding
  • Customer always available
  • Code must meet agreed standards
  • Code unit test first
  • All code is pair programmed
  • One pair integrates code at a time
  • Integrate often
  • Collective code ownership
  • Optimize last
  • NO OVERTIME

10
Testing
  • All code has unit tests
  • All tests must pass before release
  • New bugs generate new tests
  • Acceptance tests run often and scores published
  • For more information check out
  • www.extremeprogramming.org

11
White Box Testing
  • Explicit knowledge of code is required
  • Every line of code is tested
  • Every path through every if is executed
  • Done by programmer who wrote the code

12
Black Box Testing
  • Internal workings of code is UNKNOWN to tester
  • Tester knows what valid input is and what is
    expected to be done to the input
  • Tester doesnt care how it is done
  • Tester NEVER looks at the code
  • Cont.

13
Black Box Testing cont
  • Advantages
  • Test is unbiased
  • Tester doesnt need knowledge of language used to
    program
  • Viewpoint is that of user, not designer
  • Test cases can be written as soon as
    specifications are complete
  • Cont.

14
Black Box Testing Cont.
  • Disadvantages
  • Some redundancy
  • Test cases are difficult to design
  • Testing all program paths not possible

15
Black Box vs White Box Testing
  • Both are needed to ensure working code
  • In keeping with XP philosophy
  • Write test case before writing code
  • All tests must pass for integration

16
Ministry Expectations on TestingProgramming
Stream
  • TIK2O TFV.01, TFI.02, TFI.03, TF3.05, SPV.01,
    SPV.03, SP1.05, SP3.10, SP3.11, ICV.03
  • ICS3M TFV.02, TF1.01, TF1.03, TF1.05, TF2.10,
    SPV.01, SP1.04, SP1.05, SP1.08, SP2.12, SP2.13,
    SP2.14, SP2.15, ICV.03
  • ICS4M TFV.01, TF1.01, TF1.02, TF1.06, SPV.01,
    SPV.02, SPV.05, SP1.01, SP1.07, SP1.08, SP2.10,
    SP2.13, IC3.01

17
Ministry Expectations on Testing Engineering
Stream
  • TEE2O SPV.04, SP3.03
  • ICE3M TFV.05, SP2.02, SP3.01, SP3.02
  • ICE3E SPV.01, SP1.04, SP1.05, SP1.09, SP2.04,
    SP2.05, SP2.06
  • ICE4M SPV.05, SP2.04, SP3.02
  • ICE4E TF2.04, SPV.03, SP1.05, SP1.06, SP1.07,
    SP1.08, SP1.09, SP1.10, SP1.11, SP1.17

18
Making Testing Fun
  • Students love to find errors with our work
  • Provide them with programs that intentionally do
    not work
  • Let them
  • Find the errors
  • Fix the errors

19
Example
  • Program is written to convert valid integers (-32
    768 to 32 767) into words
  • Eg -25 -gt negative twenty-five
  • Eg 372 -gt three hundred and seventy- two

20
Test Plan
21
Test the Program
  • On computer, double click the program
  • NUMWORD.EXE

22
The Program Screen
23
Continuing
  • Give them the source
  • Have them fix the errors
  • They also fix their test plan errors
  • gt 80 of programming is in maintenance/repair mode

24
Errors
  • Did you find any errors?
  • Was your test plan complete?
  • What was missing from your plan?

25
Tools for Testing
  • Some IDEs have tools built in
  • BlueJ has 2 particularly useful testing features
  • Individual Class Testing
  • Unit Testing Record and Capture

26
BlueJ Individual Class Testing
  • BlueJ has a workbench
  • Can add instances of any class
  • Can run any class methods
  • Can inspect the variables

27
The Diary Project
  • A simple project that will allow us to book
    appointments during a weekday of 9-5.
  • Appointments must be multiples of one hour in
    length
  • Appointments must start on the hour

28
BlueJ
  • Open BlueJ
  • Open the project diary-prototype
  • 3 classes week, day, appointment
  • Right click on a class to create an instance

29
The BlueJ Screen
30
The Inspect Window
31
Tasks
  • Create several appointment objects, some of
    length 1 and 2 hours
  • Create a day object
  • Try to book appointments at 900 am, 100 pm and
    500 pm
  • Try to book a second appointment at 900 am
  • Try some other tests

32
The Method Result
33
Inspecting
  • Lets inspect the day object
  • Right click on day instance and choose inspect

34
Following the Arrows cont
  • Click on an appointment

35
Following the Arrows
  • Click on the appointment arrow and click inspect

36
BlueJ Unit Testing Record and Capture
  • Predefine a test condition
  • Record tests
  • Can rerun them at any time
  • Tools -gt preferences -gt miscellaneous -gt show
    testing tools

37
Creating a TestCase
  • Right click on appointment class
  • Create test class
  • Right click on test class
  • Object bench to test fixture
  • Right click on test class
  • Create test method
  • Give name
  • Run Test
  • End

38
Try This
  • Right click on Test Appointment class
  • Test Fixture to Object Bench
  • Create Test Day class
  • Right click on Test Day class
  • Object Bench to Test Fixture

39
Try This cont
  • Create Day Test method named AddDuplicate
  • Add an appointment for 9
  • Assert that result is false
  • End
  • Run the tests

40
Try This cont
  • Create Day Test method named AddNew
  • Add an appointment for 10
  • Assert that result is false
  • End
  • Run the tests

41
Results
  • Notice that the AddNew test failed.
  • Why??

42
Adding Tests Manually
  • Open Editor on Day Test class
  • Observe the methods
  • Setup creates the Object Bench
  • Each Test has its own method
  • Fix the TestNew method to assert True
  • Try the tests again

43
Explore
  • There are several projects available to you to
    try out
  • Inspect them
  • Fix them
  • Enjoy them

44
Recap
  • Testing philosophies
  • Function Testing
  • Unit Testing
  • BlueJ

45
Resources
  • Extreme Programming
  • www.extremeprogramming.org
  • BlueJ
  • www.bluej.org
  • Karel the Robot
  • www.learningwithrobots.com
  • My email
  • Eileen.Landa_at_yrdsb.edu.on.ca
Write a Comment
User Comments (0)
About PowerShow.com