Software Testing and Reliability
Software Testing and Reliability
Reliability
SWE30009
Project Report
Nguyen Manh Duc –
103792724
Task 1: Random testing
Subtask 1.1:
1. Define input domain: Determine the valid input ranges and types.
2. Select distribution profiles: Choose appropriate distributions for
generating test data.
3. Generate test cases: Randomly create test data based on the
defined distributions.
4. Execute test cases: Run the software with the generated test
cases.
5. Analyze results: Evaluate software behavior and identify defects.
Subtask 1.2:
To generate random test case for program that sorts a non-empty list of
integers with potential duplicates, we can follow these steps:
Test Case 1:
o List length: 30
o Integer range: -200 to 200
o Duplicate probability: 40%
o Generated list: [-123, 45, 78, -90, 12, 45, -10, 32, 111, -55, 78, 3, 22, -33, 0, 4,
-12, 25, 1, -7, 45, -123, 0, 99, -200, 150, 67, -8]
Test Case 2:
o List length: 8
o Integer range: -5 to 5
o Duplicate probability: 60%
o Generated list: [2, -3, -3, 2, 5, -1, -3, 0]
By creating multiple test cases with varying list lengths, integer ranges, and duplicate
probabilities, we can increase the chances of uncovering potential issues in the sorting
program.
While random testing is effective, it is often combined with other testing techniques like
equivalence partitioning and boundary value analysis for more comprehensive test coverage.
Metamorphic Relations
2. Generate test cases: Create initial test cases using any suitable
technique (e.g., random, equivalence partitioning).
3. Apply metamorphic relations: Use the initial test cases and MRs
to generate new test cases.
4. Execute test cases: Run the program with the generated test
cases.
Example: A search engine can be tested using MRs like "if query A is a
substring of query B, then the result set for A should be a subset of the
result set for B."
Subtask 2.2:
Problem:
Test a program that sorts a non-empty list of integer numbers which may
contain duplicated numbers.
MR1: Idempotency
Metamorphic Group:
o Test case 2: The sorted version of the list from test case 1.
Metamorphic Group:
o Test case 1: A randomly generated list of integers.
o Test case 2: The sorted version of the list from test case 1.
Metamorphic Group:
o Test case 2: The sorted version of the list from test case 1.
MR4: Monotonicity
Metamorphic Group:
o Test case 2: The sorted version of the list from test case 1.
Subtask 2.3:
Simple to implement
3. Metamorphic Relations
Detailed Description of MR1: Reversing the Input Array
Description: Reversing the input array should yield the same result when
sorted, regardless of the initial order of the elements. This metamorphic
relation ensures that the sorting algorithm is consistent and correct,
irrespective of the input's order.
Purpose: By reversing the array and sorting it again, we confirm that the
sorting algorithm behaves correctly regardless of the initial ordering of
elements.
Purpose: This test verifies that the sorting algorithm preserves the
relative order of elements even if a constant is uniformly added to each
element of the array.
4. Testing Process
Implementation Steps
3. Generate Mutants:
Execution
2. Expected Output:
When executed, the original program should produce the following output:
Results
The original program should successfully sort the array and produce the
correct sorted output. This output serves as the reference for evaluating
the effectiveness of the metamorphic relations and mutant testing.
Mutant Generation
1. Introduce Mutations:
5. Results
Tables and Figures Showing Mutant Analysis
To evaluate the effectiveness of the metamorphic relations (MRs) in
detecting faults, we conducted tests on various mutants of the bubble sort
algorithm. The results are summarized in the table below, which shows
whether each mutant passed the defined MRs and includes remarks on
the findings.
Mutant
MR1 Passed MR2 Passed Remarks
ID
Mutant
Yes Yes -
10
Mutant
Yes Yes -
11
Mutant
Yes Yes -
12
Mutant
Yes Yes -
13
Mutant
Error - List index out of range
14
Mutant
Yes Yes -
15
Mutant
Yes Yes -
16
Mutant
MR1 Passed MR2 Passed Remarks
ID
Mutant
Yes Yes -
17
Mutant
No Yes MR1 failed for reversed input
18
Mutant
Yes Yes -
19
Mutant
Yes Yes -
20
Discussion:
The testing of the bubble sort algorithm with various mutants revealed
that metamorphic testing can effectively identify certain types of faults,
particularly those affecting the sorting logic. Specifically, MR1 proved to
be a valuable tool in detecting issues related to comparison and swapping
operations. The effectiveness of MR2 was limited in this case, suggesting
that additional or alternative metamorphic relations might be needed to
cover a broader range of faults.