Activity: Syntax-based testing (Grammar)

(no submission)

Purpose: Understand the basic concept of syntax-based testing (focus on Grammar-based mutation); get ready to work on homework assignment, and prepare for the final exam.

You may make a copy of a worksheet and complete this activity, or type your answers in any text editor.

You may work alone or with at most two other students in this course.


Consider the following BNF and answer the questions
  A ::= MO | MB | MOB
  M ::= "1" | "2" | "3" | "4"
  O ::= "e" | "a" | "t" 
  B ::= "h" | "u" | "n" | "g" | "r" | "y" | "w"   
  1. How many nonterminal symbols are in the grammar?
       4 

  2. How many terminal symbols are in the grammar?
       14 

  3. Write two strings that are valid according to the BNF
       A ::= MO, there are 4 * 3 = 12 possible strings
       A ::= MB, there are 4 * 7 = 28 possible strings
       A ::= MOB , there are 4 * 3 * 7 = 84 possible strings
       
       124 possible valid strings, including: 1an (MOB), 2t (MO) 

  4. For each of your two strings, give two valid mutants of the string
       Dozens for each string
          Here are some possible valid mutants: 
          For 1an  —  2an (terminal symbol replacement), 1a (nonterminal symbol deletion)
          For 2t  —  2n (nonterminal symbol replacement), 2tw (nonterminal symbol insertion) 

  5. For each of your two strings, give two invalid mutants of the string
       Thousands for each string
          Here are some possible invalid mutants:
          For 1an  —  1at (MOB, terminal symbol replacement), ran (BOB, nonterminal symbol replacement)
          For 2t  —  2te (MOO, nonterminal symbol insertion), 2 (M, nonterminal symbol deletion)  

Copyright © 2025 Upsorn Praphamontripong
Released under the Creative Commons License CC-BY-NC-SA 4.0 license.
Last updated 2025-11-01 18:21