Ch5-1-overviewSyntax

Ch5-1-overviewSyntax - Introduction to Software Testing...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Introduction to Software Testing Chapter 5.1 Syntax-based Testing Paul Ammann & Jeff Offutt http://www.cs.gmu.edu/~offutt/softwaretest/ Ch. 5 : Syntax Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Applied to FSMs Source Applied to Applied to Introduction to Software Testing (Ch 5) © Ammann & Offutt 2 Use cases Specs Design Source DNF Specs Input Models Integ Source
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Using the Syntax to Generate Tests (5.1) Lots of software artifacts follow strict syntax rules The syntax is often expressed as some sort of grammar such as BNF Syntactic descriptions can come from many sources Programs Integration elements Design documents Input descriptions Tests are created with two general goal Introduction to Software Testing (Ch 5) © Ammann & Offutt 3 Tests are created with two general goals Cover the syntax in some way Violate the syntax (invalid tests) Grammar Coverage Criteria Software engineering makes practical use of automata theory in several ways Programming languages defined in BNF Program behavior described as finite state machines Allowable inputs defined by grammars A simple regular expression: ( G s n | B t n ) * * ’ is closure operator, zero or more occurrences | choice , either one can be used Introduction to Software Testing (Ch 5) © Ammann & Offutt 4 Any sequence of “ G s n ” and “ B t n G ’ and ‘ B ’ could be commands, methods, or events s ’, ‘ t ’, and ‘ n ’ could represent arguments, parameters, or values s ’, ‘ t ’, and ‘ n ’ could be literals or a set of values
Background image of page 2
3 Test Cases from Grammar A string that satisfies the derivation rules is said to be “ in the grammar A test case is a sequence of strings that satisfy the regular expression Suppose ‘s’, ‘t’ and ‘n’ are numbers G 21 08 01 90 B 17 06 27 94 Could be one test with four parts Introduction to Software Testing (Ch 5) © Ammann & Offutt 5 G 16 11 21 94 B 08 01 09 03 Could be one test with four parts, four separate tests, . . . BNF Grammars Stream ::= action* action ::= actG | actB Start symbol action ::= actG | actB actG ::= “G” s n actB ::= “B” t n s ::= digit 1-3 t ::= digit 1-3 Non-terminals Terminals Production rule Introduction to Software Testing (Ch 5) © Ammann & Offutt 6 n ::= digit 2 “.” digit 2 “.” digit 2 digit ::= “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9”
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Using Grammars Stream ::= action action * ::= actG action* ::= G s n action* Recognizer : Given a string (or test), is the string in the grammar ? ::= G digit 1-3 digit 2 . digit 2 . digit 2 action* ::= G digitdigit digitdigit.digitdigit.digitdigit action* ::= G 20 08.01.90 action* Introduction to Software Testing (Ch 5) © Ammann & Offutt 7 This is called parsing Tools exist to support parsing Programs can use them for input validation Generator : Given a grammar, derive strings in the grammar Mutation as Grammar-Based Testing Grammar-based Testing UnMutated Derivations ( valid strings ) Mutated Derivations ( invalid strings ) GM t
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

Ch5-1-overviewSyntax - Introduction to Software Testing...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online