F. Tip And M. FUNCTIONAL TESTING Weintraub

2y ago
19 Views
2 Downloads
4.09 MB
68 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Abby Duckworth
Transcription

F. Tip and M.WeintraubFUNCTIONAL TESTING

ACKNOWLEDGEMENTSThanks go to Andreas Zeller for allowing incorporation of his materials2

HOW TO TELL IF A SYSTEM MEETSEXPECTATIONS?Two options:1. testing: execute parts of the program and observe if unexpectedbehaviors occur2. formal verification: exhaustively enumerate all states of the system,and try to prove that properties to be verified hold in each state. Various techniques, e.g. model checking

THE FIRST COMPUTER BUG (1947)The First "Computer Bug". Moth found trapped betweenpoints at Relay # 70, Panel F, of the Mark II Aiken RelayCalculator while it was being tested at HarvardUniversity, 9 September 1947.The operators affixed the moth to the computer log, withthe entry: "First actual case of bug being found". Theyput out the word that they had "debugged" the machine,thus introducing the term "debugging a comp.uterprogram".In 1988, the log, with the moth still taped by the entry,was in the Naval Surface Warfare Center ComputerMuseum at Dahlgren, Virginia. The log is now housed atthe Smithsonian Institution’s National Museum ofAmerican History, who have corrected the date from1945 to 1947. Courtesy of the Naval Surface WarfareCenter, Dahlgren, VA., 1988. NHHC PhotographCollection, NH 96566-KN (Color).From 06563343.78834.76845133343/10153057920928344/

WHAT TO TEST?Configurations

DIJKSTRA’S CURSETesting can only find the presence of errors,but not their absenceConfigurations

FORMAL VERIFICATIONConfigurations

Level of AbstractionFORMAL VERIFICATIONConfigurations

FORMAL VERIFICATIONLevel of AbstractionDesign or Specification LevelConfigurations

FORMAL VERIFICATIONLevel of AbstractionDesign or Specification LevelHigh Level FrameworkConfigurations

FORMAL VERIFICATIONLevel of AbstractionDesign or Specification LevelHigh Level FrameworkCode LevelConfigurations

FORMAL VERIFICATIONLevel of AbstractionDesign or Specification LevelHigh Level FrameworkCode LevelAssemblyConfigurations

FORMAL VERIFICATIONLevel of AbstractionDesign or Specification LevelHigh Level FrameworkCode LevelAssemblyOSHardwareConfigurations

ZELLER’S COROLLARYLevel of AbstractionDesign or Specification LevelHigh Level FrameworkCode LevelVerification can only find the absence of errors,but never their presenceAssemblyOSHardwareConfigurations

Level of AbstractionBACK TO TESTING: HOW TO COVER AS MUCH OFTHE SPACE AS POSSIBLE?Configurations

FUNCTIONAL TESTING – AKA BLACK BOX TESTING

WHITE BOX TESTING IS WHERE YOU TEST BASEDON KNOWING WHAT’S INSIDE THE MODULE

IF WE CANNOT KNOW THE CODE INSIDE, AGAINSTWHAT DO WE WRITE TESTS?

IF WE CANNOT KNOW THE CODE INSIDE, AGAINSTWHAT DO WE WRITE TESTS?Specifications

TESTING TACTICSFunctional/Black BoxStructural/White Box Tests based on spec Tests based on code Test covers as muchspecified behavioras possible Test covers as muchimplemented behavioras possible

WHY DO FUNCTIONAL TESTING?Functional/Black Box1. Program code not necessary2. Early functional test design has benefits1. Reveals spec problems2. Assesses testability3. Gives additional explanation of spec4. May even serve as spec, as in XPStructural/White Box

WHY DO FUNCTIONAL TESTING?Structural/White BoxFunctional/Black Box Best for missing logic defects Common problem:Some program logic was simplyforgottenStructural testing would not focus oncode that is not there Applies at all granularity levels unit tests integration tests system tests regression tests

RANDOM TESTING Pick possible inputs uniformly Avoids designer biasA real problem: The test designer can make the same logicalmistakes and bad assumptions as the program designer (especially ifthey are the same person) But treats all inputs as equally valuable

AngleForce

INFINITE MONKEY THEOREM

INFINITE MONKEY THEOREMIf you put enough monkeys in front of typewriters and givethem enough time, you eventually will get Shakespeare

Youtube

Angle232 4.294.967.296different valuesForce232 4.294.967.296different values

18,446,744,073,709,551,616 COMBINATIONS 18,446,744,073,709,551,616

THE ALTERNATIVE: COMPUTER SCIENCEAPPROACHESComputer scientists are smart,and they can systematically testand analyze programs.

SYSTEMATIC FUNCTIONAL ytestable vegenerateTest caseTest casespecifications

TESTABLE lytestable feature Decompose system intoindependently testable features (ITF) An ITF need not correspond to units or subsystems of the software For system testing, ITFs are exposed through user interfaces or APIs

WHAT ARE THE INDEPENDENTLY TESTABLEFEATURES?class Roots {// Solve ax2 bx c 0public roots(double a, double b, double c){ }// Result: values for xdouble root one, root two;}

EVERY FUNCTION IS AN INDEPENDENTLYTESTABLE FEATURE Consider a multi-functioncalculator What are the independentlytestable features?

REPRESENTATIVE VALUES Try to select inputsthat are especiallyvaluable Usually by choosingrepresentativesof equivalence classes thatare apt to fail oftenor not at allIndependentlytestable vegenerateTest caseTest casespecifications

LIKE FINDING NEEDLES IN A HAYSTACKTo find bugs systematically, weneed to find out what makescertain inputs or behaviorsspecial

SYSTEMATIC PARTITION TESTINGThe space of possible input values(the haystack)Failure (valuable test case)No failureFailures are sparse insome regions ofpossible inputs .If we systematically test some casesfrom each part, we will include thedense parts. but dense in otherFunctional testing is one way ofdrawing lines to isolate regions withlikely failures

EQUIVALENCE PARTITIONINGInput conditionEquivalence classesrangeone valid, two invalid (larger andsmaller)specific valueone valid, two invalid (larger andsmaller)member of a setone valid, one invalidbooleanone valid, one invalidDefining equivalence classes comes from input conditionsin the spec. Each input condition induces an equivalenceclass – valid and invalid inputs.

BOUNDARY ANALYSIS – FINDING ERROR AT THEEDGESPossible test caseat lower rangeTest(valid and invalid)at centerat higher range(valid and invalid)

EXAMPLE: ZIP CODE Input: 5-digit ZIP code Output: list of citiesWhat are representative valuesto test?

VALID ZIP CODES1. With 0 cities as output(0 is boundary value)2. With 1 city as output3. With many cities as output

INVALID ZIP CODES4. Empty input5. 1–4 characters(4 is boundary value)6. 6 characters(6 is boundary value)7. Very long input8. No digits9. Non-character data

“SPECIAL” ZIP CODES1. How about a ZIP code that reads12345‘; DROP TABLE orders; SELECT * FROMzipcodes WHERE ‘zip’ ‘2. A ZIP code with 65536 characters This is security testing

OR, YOU CAN USE MODELS TO DEFINE TESTSidentify Use a formal modelthat specifies software behavior Models typically come as finite state machines andIndependentlytestable featureidentifyRepresentativevaluesderiveModel decision structuresderiveTest casespecifications

FINITE STATE MACHINE FOR 7689

COVERAGE CRITERIA1. Path coverage: Tests cover every path Not feasible in practiceCycles create infinite pathsAcyclic graphs can still have an exponential number of paths2. State coverage: Every node is executed A minimum testing criterion3. Transition coverage: Every edge is executed Typically, a good coverage criterion to aim for

TRANSITION COVERAGE0Each test case covers a set oftransitions1Here, there are five needed to covereach transition onceone color one test case23457689

STATE-BASED TESTING Protocols (e.g., network communication) GUIs (sequences of interactions) Objects (methods and states)

DECISION TABLES Some specifications define decision tables, decision trees, or flow charts. We candefine tests from these structures.Type of ucation accountTTFFFFFFCurrent purchase Threshold 1––FFTT––Current purchase Threshold 2––––FFTTSpecial price scheduled priceFTFT––––Special price Tier 1––––FT––Special price Tier 2––––––FTEdu discountSpecialpriceOutcomeNodiscountTier 2Special Tier 1 d SpecialSpecialdiscounpricePriceprice iscountt

CONDITION COVERAGE Basic Criterion: each condition should be evaluated once using each possible setting “Don’t care” entries (–) can take arbitrary values Compound Criterion: Evaluate every possible combination of values for the conditions Decision Coverage: the expression should be evaluated once so it results in eachpossible outcome Modified Condition/Decision Coverage (MC/DC) Each decision takes every possible outcome Each condition in a decision takes every possible outcome Each condition in a decision is shown to independently affect the outcome of thedecision. used in safety-critical avionics software details in Pezze Young, “Software Testing and Analysis”, Chapter 14

LEARNING FROM THE PAST

PARETO’S LAWApproximately 80% of defectscome from 20% of modules

DERIVING TEST lytestable vegenerateTest caseTest casespecifications

COMBINATORIAL abase

COMBINATORIAL TESTING1. Eliminate invalid combinations IIS only runs on Windows, for example2. Cover all pairs of combinationssuch as MySQL on Windows and Linux3. Combinations typically generated automaticallyand – hopefully – tested automatically, too

PAIRWISE TESTING MEANS TO COVER EVERYSINGLE PAIR OF ySQLOracleLinuxApacheMySQLOracleLinuxLinux

RUNNING A TESTA test case 1. sets up an environment for the test2. tests the unit3. tears down the environment againTests are organized into suites

TESTING A URL CLASShttp://www.askigor.org/status.php?id sampleProtocolHostPathQuery

JUNIT EXAMPLEpackage junitexample;public class Calculator {int add(int value1, int value2) {return value1 value2;}int subtract(int value1, int value2) {return value1 - value2;}int multiply(int value1, int value2) {return value1 * value2;}int divide(int value1, int value2) {return value1 / value2;}}

JUNIT, PART DEUXpackage junitexample;import junit.framework.TestCase;public class CalculatorTest extends TestCase {private Calculator calc;public CalculatorTest(String s){super(s);}// called before each testprotected void setUp() throws Exception {super.setUp();calc new Calculator();}// called after each testprotected void tearDown() throws Exception {super.tearDown();} // test for the add() methodpublic final void testAdd() {assertEquals(calc.add(20, 30), 50);}// test for the subtract() methodpublic final void testSub() {assertEquals(calc.subtract(20, 10), 10);}// test for the multiply() methodpublic final void testMult() {assertEquals(calc.multiply(9, 11), 99);}// test for the divide() methodpublic final void testDiv() {assertEquals(calc.divide(18, 2), 9);}}

JUNIT INTEGRATION IN ECLIPSE

TEST-DRIVEN DEVELOPMENT writing tests before you implement functionality involves extraeffort, but it forces you to think about the problem you are trying tosolve more concretely and formulate a solution more quickly and you will regain the time spent on unit tests by catchingproblems early and reduce time spent later on debugging

RECOMMENDATIONS FOR WRITING GOOD TESTS write tests that cover a partition of the input space, and that coverspecific features achieve good code coverage create an automated, fast running test suite, and use it all the time have tests that cover your system’s tests at different levels offunctionality set up your tests so that, when a failure occurs, it pinpoints the issue sothat it does not require much further debugging

EXTRA

TESTING ENVIRONMENTS ARE OFTEN COMPLEX Millions of configurations Testing on dozens of differentmachines All needed to find andreproduce problems

DEFECT SEVERITY An assessment of a defect’s impact Can be a major source of contention between dev and testCriticalMajorShow stopper. The functionality cannot be delivered unlessthat defect is cleared. It does not have a workaround.Major flaw in functionality but it still can be released. There is aworkaround; but it is not obvious and is difficult.minor functionality or non-critical data. There is an easyMinor Affectsworkaround.TrivialDoes not affect functionality or data. It does not even need aworkaround. It does not impact productivity or efficiency. It ismerely an inconvenience.

Test case generate SYSTEMATIC FUNCTIONAL TESTING. Functional specification Independently testable feature identify . (valuable test case) No failure SYSTEMATIC PARTITION TESTING Failures are sparse in some regions of . JUNIT EXAMPLE package junitexample; public class Calculator {int add(int value1, int value2)

Related Documents:

Tip 14 - Group Photos Made Easy Tip 15 - Rare Rainy Day Photos Tip 16 - Controlling Color in Indoor Photos Tip 17 - Sharp Action Photos Tip 18 - Landmarking Landscape Photos Tip 19 - Better Digital Photo Color Tip 20 - Portrait Photos that Impress Tip 21 - Flash and Action (Flash Freeze) Tip 22 - Using Depth of Field

The range will not tip during normal use. However, the range can tip if you apply too much force or weight to the open door wit hout the anti-tip bracket fastened down properly. Tip Over Hazard A child or adult can tip the range and be killed. Connect anti-tip bracket to rear range foot. Reconnect the anti-tip bracket, if the range is moved.

In 30 PICC insertions, we adopted Navigator (Corpak) for tip navigation and IC-ECG for tip location (performed using Nautilus, Romedex). The Navigator device consists of a sterile stylet (diameter 1.1 Fr, length 106 cm) placed inside the catheter so that the tip of the stylet is at 1 mm from the tip. During insertion, the tip of the

NSW Small Business Commissioner Visual merchandising for small businesses 2019 Tip 1: Shop your shop 2 Tip 2: Work your windows 3 Tip 3: Colour me happy 4 Tip 4: Tell a story, sell a story 5 Tip 5: Visual organisation using shapes and patterns 6 Top 6: Hot zone merchandising 7 Tip 7: Promotional merchandising 8

Numeric Functional Programming Functional Data Structures Outline 1 Stuff We Covered Last Time Data Types Multi-precision Verification Array Operations Automatic Differentiation Functional Metaprogramming with Templates 2 Numeric Functional Programming Advanced Functional Programming with Templates Functional Data Structures Sparse Data Structures

Part of original welding kit. 6) T20004 Fillet Weld Tip ¼" fillet weld tip used for butt and right angle welds. 7) T20005 Fillet Weld Tips 3/8" fillet weld tip used for butt and right angle welds. 8) T20011 Fillet Weld Tips ½" fillet weld tip used for butt and right angle welds. 9) T20009 Ribbon Weld Tip used for welding thermoplastic

The tip speed of the rotor is a function of the rate of rotation of the rotor specified by its r.p.m.: in each revolution of the rotor, the tip traverses a distance and so the tip speed is A convenient way to express rotor efficiency is in terms of the tip speed ratio , where TIP SPEED RATIO W Sd Sm .) t

1. the most useful tip? 2. a tip you already use? 3. a tip you would never use? 4. a tip you would like to try? 16 Me, too. I always buy things too quickly! 1. advertising 2. decide 3. producer 4. repeat I think the most useful tip is, “wait 24 hours.” headline visual copy tagline logo 3 ad / advertisers