+ All Categories
Home > Documents > MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

Date post: 03-Apr-2018
Category:
Upload: meljun-cortes-mbampa
View: 222 times
Download: 0 times
Share this document with a friend

of 23

Transcript
  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    1/23

    Software Engineering 1

    Software Testing

    Testing YourPrograms

    TOPIC THREE

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    2/23

    Software Engineering 2

    Program Testing

    Unit Testing

    Integration Testing

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    3/23

    Software Engineering 3

    Unit Testing

    It is the basic level of testing.

    It has intention to test smaller building blocks of a program.

    It is the process of executing each model to confirm that

    each performs its assigned function. It involves testing the interface, local data structures,

    boundary conditions, independent paths and error handlingpaths.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    4/23

    Software Engineering 4

    Unit Test Environment

    Driver

    stub stub

    result

    TESTCASES

    COMPONEN

    T

    or

    MODULE

    input

    data

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    5/23

    Software Engineering 5

    Object-oriented Testing

    The smallest testable unit of a class is the methods of theclass.

    Testing should be in the context to which the objects of the

    class are instantiated.

    The method draw() should be tested in all subclasses thatinherit it.

    Shape

    draw()

    CircleSquare Rectangle

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    6/23

    Software Engineering 6

    Integration Testing

    It verifies that each component performs correctly within thecollaboration and that each interface is correct.

    The control structure of the architecture of the program

    dictates integration testing. For object-oriented software, two approaches are used:

    Thread-based Testing Approach

    Use-based Testing Approach

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    7/23

    Software Engineering 7

    Thread-based Testing

    Approach It is a test based on a group of classes that collaborate or

    interact when one input needs to be processed or one eventhas been triggered.

    A thread is a path of communication among classes. The sequence diagrams or collaboration diagrams can be

    used to perform this kind of test.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    8/23

    Software Engineering 8

    Thread-based Testing

    Example

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    9/23

    Software Engineering 9

    Thread-based Testing

    Example The test would involved the following: The club staff will click the FindButton of theAthleteRecordUI.

    FindAthleteRecordUIScreen will be displayed.

    The club staff will click the OKButton which will instantiate theFindAthleteRecordcontroller.

    The FindAthleteRecordcontroller communicates with the DBAthleteto populate the PCLAthlete.

    TheAthleteListUIscreen will be displayed to show a list of athletes

    that satisfy the criteria. The club staff highlights the name of the athlete he wants.

    The club staff clicks OKButton or presses enter.

    TheAthleteRecordUIscreen should display the athlete informationon the appropriate test field.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    10/23

    Software Engineering 10

    Use-based Testing Approach

    It makes use ofindependent classes. They are ones that donot use other classes.

    After testing the independent classes, the immediatedependent classes are tested.

    Clustering is the process of defining a set of glasses thatare integrated and tested together. They are calledclusters because they are considered as a unit.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    11/23

    Software Engineering 11

    Use-based Testing Approach

    Example

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    12/23

    Software Engineering 12

    Use-based Testing Approach

    Example The test involves the following: Either testAthlete orPCLAthlete classes.

    If the classes are OK, test the DBAthlete class.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    13/23

    Software Engineering 13

    Test-driven Development

    It is a method of developing software that adopts a test-firstapproach plus refactoring.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    14/23

    Software Engineering 14

    Test-first Approach

    It is a programming technique involving analysis, design,coding and testing all together.

    Two basic steps are involved:

    Write just enough test to describe the next increment of behavior. Write just enough product code to pass the test.

    As the name implies, one writes the test first.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    15/23

    Software Engineering 15

    Refactoring

    It means improving the design of the existing code.

    It is a systematic way of improving the design of the code byremoving redundant or duplicate code.

    It is a process of changing code so that the internal structureof the code is improved without changing the behavior of theprogram.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    16/23

    Software Engineering 16

    Benefits of Test-driven

    Development (TDD) It allows simple incremental development. It involves a simpler development process.

    It provides constant regression testing.

    It improves communication. It improves the understanding of required software behavior.

    It centralizes knowledge.

    It improves software design.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    17/23

    Software Engineering 17

    TDD Steps

    1. Write a test that defines how the software should behave.

    2. Make the test run as easily and quickly as possible.

    3. Clean up the code.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    18/23

    Software Engineering 18

    STEP 1: Write a test.

    The test should define the behavior of the software. As anexample, consider the following code:

    A he etmy=P LtleteList. eAthle e355)A heettsistmyttsti =n wAheettsistmy;

    / /Add s hoo t ing a ver a ge s t at i s tic s s h oot i ng 1 f o r 9 a t t e m pt s/la st my ttsics.a dhotingAver g("8/9 20",1 9);

    / /Add s hoo t ing a ver a ge s t at i s tic s s h oot i ng 4 f o r 10 a t t e mp ts/ last8/16/2004 game.t my ttsics.a dhotingAver g("8/1 /04", ,10 ;

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    19/23

    Software Engineering 19

    STEP 1: Write a test.

    //t mmy ttstics.addShootingAverage("8/25/2004",7 ,10 ;/ Com uefortheshootingaverageforgame8/16fl otgameShotingAverage=t immyStatis ti cs. g etGa m eSh o oti n g Av e r age ( 8 / 16/ 2 00 5' ) ;/ Cfl otseasonSootingAverae=t m// Cekgamehootingaveaea s

    //C ekgamehootingaveraea s

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    20/23

    Software Engineering 20

    STEP 2: Make the test run.

    Write the class that would support the behaviors asspecified in the test. Consider the following code:

    p bilstltSaitcs{pri aeAheeapivateStatisticstats;

    / cntutrwttltaraterp b//pe te .a= tetlt;sats=newStati tics();}

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    21/23

    Software Engineering 21

    STEP 2: Make the test run.

    int shot sin te pts ) {

    //place here code of adding statistics for the game.

    }

    pub

    //place computation here.

    }

    p b

    //place computation here.

    }}

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    22/23

    Software Engineering 22

    STEP 3: Clean up the code.

    When the code is running properly, take a step back therefactor the codes to remove any duplication or any otherproblem that was introduced to get the test running.

    Do not be afraid to refactor your code. If you break thecode, the unit test will let you know immediately.

  • 7/29/2019 MELJUN CORTES JEDI Slides-6.3 Testing Your Programs.sxi

    23/23

    Software Engineering 23

    Summary

    Testing Your Program Unit Testing

    Integration Testing

    Thread-based Testing Approach

    Use-based Testing Approach Test-driven Development (TDD)

    Test-first

    Refactoring

    Benefits of TDD TDD Steps


Recommended