Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: zz-x2580
The goal of this task is to apply unit testing to find bugs in st1920.automaton in a black-box fashion, that is, following its functional specification rather than its source code structure.
Functional specification of the system under test. The system under test provides a utility class RegExpMatcher with a single static method that serves as an interface to the entire package:
public static boolean matches(String m, String re)
This method returns true if the string m matches the pattern specified by the regular expression re, and false otherwise.
pattern1 | pattern2 matches either pattern1 or pattern2
pattern1 & pattern2 matches both pattern1 and pattern2
pattern1 pattern2 matches pattern1 followed by pattern2
pattern ? matches zero or one occurrence of pattern
pattern * matches zero or more occurrences of pattern
pattern + matches one or more occurrences of pattern
pattern {n} matches n occurrences of pattern
pattern {n,} matches n or more occurrences of pattern
pattern {n,m } matches between n and m occurrences of pattern
~ pattern matches the patterns excluded by pattern
[ charclass1 charclass2 . . . ] matches a character belonging to at least one of char- class1, char-class2 . . .
[^ charclass1 charclass2 . . . ] matches a character not belonging to any of char-class1,
char-class2 . . . (a character class charclass is either a single character c or a character range c1 –c2 )
. matches any single character
# does not match anything
@ matches any string
string ” matches the entire string string
< n – m > matches a number between n and m
Table 1: Regular expression operations in st1920.automaton.
For example, the following regular expression defines syntactically valid email addresses:
([a-zA-Z0-9])+\@([a-zA-Z0-9])+\.([a-z]){2,3}
Patterns within regular expressions can be enclosed in parenthesis to enforce the desired operator precedence. Reserved characters (|&?*+,~^.#@”<>()\) can be used as regular characters by escaping them with backslash (\) or double quotes (“”). Ill- formed regular expressions lead to exceptions of type IllegalArgumentException.
If you want to learn more about regular expressions and the rich body of theory underlying them, see for example the classic text of Hopcroft et al. “Introduction to Automata Theory, Languages, and Computation”.
Target bugs. We have injected 15 different bugs in the st1920.automaton pack- age. The estimated difficulty of finding these bugs ranges from easy (5 bugs), to medium (5 bugs), to hard (5 bugs). All bugs can be triggered using appropriate calls to the matches method in the utility class RegExpMatcher. For clarity, the bugs are numbered and manifest themselves as exceptions triggered with the following error message:
java.lang.IllegalStateException: Bug <N> found (<DIFFICULTY>).
where <N> indicates the bug number (from 1 to 15) and <DIFFICULTY> indicates the estimated difficulty of finding the bug.
Assessment. This task will be assessed by counting the number of different bugs that are triggered by the test cases in Task1.java, weighted by their level of diffi- culty: easy bugs are worth 1 point, medium bugs are worth 2 points, and hard bugs are worth 3 points.
submit st cw1 Task1.java
The goal of this task is to measure and analyze the branch coverage of the st1920.automaton code achieved by executing the test cases developed in Task 1. The measurements should exclude coverage of the test cases themselves. The easiest way to achieve this with EclEmma is by placing the test classes under a separate directory, for example test/st1920/automaton.
Submission. To submit your work you should designate one member of the group as a submitter for the group. The submitter will gather the deliverable for the task and execute this command on a DICE machine:
Task 2: Analyzing Code Coverage [5 points]
Tip: if you run out of ideas to create new test cases, you can try to apply automatic unit test generation using the Randoop tool as described in Task 3.