The document describes code for finding, setting, and mutating queens on a chessboard during a software testing project. It includes the code, flow diagrams, cyclomatic complexity calculations, test cases, and data flow graphs for 5 methods: findQueen(), setQueen(), toString(), occurMutation(), and getCopy(). The methods find and set the position of queens, output the board, randomly mutate queen positions, and make a copy of the board respectively. Cyclomatic complexity and test cases are provided to evaluate each method.
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
IT Software Testing Methods
1. INSTITUTE OF INFORMATION TECHNOLOGY
UNIVERSITY OF DHAKA
Software Testing
Submitted by
Minhas Kamal
Roll- BSSE0509
Submitted to
Alim-ul-Giash
Lecturer
Institute of Information Technology,
University of Dhaka
Data: 10-Nov-15
2. Method -1: findQueen
1 private int findQueen(int row){
2 intqueenColumnNo=
3 for(int j=0; j<boardSize; j++){
4 if(boxes[row][j]==1){
5 queenColumnNo=j;
6 break;
7 }
8 }
9 return queenColumnNo;
10 }
Flow Diagram:
Cyclomatic Complexity:
1. V(G) = e - n + 2p = 7 – 6 + 2 = 3
2. V(G) = d + 1 = (1+1) + 1 = 3
3. V(G) = number of regions = 3
findQueen(int row){
intqueenColumnNo=-1;
for(int j=0; j<boardSize; j++){
if(boxes[row][j]==1){
queenColumnNo=j;
break;
return queenColumnNo;
6 + 2 = 3
V(G) = d + 1 = (1+1) + 1 = 3
V(G) = number of regions = 3
1
6. Method -2: setQueen
1 public void setQueen(int row, int column) {
2 for(int i=0; i<boardSize; i++){
3 boxes[row][i] = 0;
4 }
5
6 geneticSequence[row] = column;
7 boxes[row][column] = 1;
8 }
Flow Diagram:
Cyclomatic Complexity:
1. V(G) = e - n + 2p = 4 – 4
2. V(G) = d + 1 = 1 + 1 = 2
3. V(G) = number of regions =
Independent Paths:
1. 1, 2, 3, 4, 2, 5, 6, 7, 8
2. 1, 2, 5, 6, 7, 8 (unfeasible path)
public void setQueen(int row, int column) {
for(int i=0; i<boardSize; i++){
boxes[row][i] = 0;
geneticSequence[row] = column;
boxes[row][column] = 1;
4 + 2 = 2
V(G) = number of regions = 2
(unfeasible path)
5
7. Test Case:
Test Case ID Input
TC-1 row = 0
column = 0
boardSize = 1
Data Flow Graph for ‘row’:
Expected Output Independent Path
Covered by Test Case
boxes = {{1}}
queenColumnNo = {0}
1
6
Independent Path
Covered by Test Case
8. Data Flow Graph for ‘column’
All du-paths:
row
1-2-5-6-7
1-2-3-4-2-5-6-7
1-2-3
1-2-3-2-3
column’:
column
1-2-5-6-7
1-2-3-4-2-5-6-7
7
12. Method -4: occurMutation
1 public void occurMutation(
2 Random random = new Random();
3
4 if(randomValue
5 int rowNo = Math.abs(random.nextInt()%boardSize);
6 int columnNo = Math.abs(random.nextInt()%boardSize);
7
8 setQueen(rowNo, columnNo);
9 }
10 }
Flow Diagram:
Cyclomatic Complexity:
1. V(G) = e - n + 2p = 4 – 4
2. V(G) = d + 1 = 1 + 1 = 2
3. V(G) = number of regions = 2
Independent Paths:
1. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
2. 1, 2, 3, 4, 10
public void occurMutation(int randomValue){
Random random = new Random();
%10==0){
rowNo = Math.abs(random.nextInt()%boardSize);
columnNo = Math.abs(random.nextInt()%boardSize);
setQueen(rowNo, columnNo);
4 + 2 = 2
number of regions = 2
10
11
rowNo = Math.abs(random.nextInt()%boardSize);
columnNo = Math.abs(random.nextInt()%boardSize);
13. Test Case:
Test Case ID Input
TC-1 random = 100
TC-2 random = 97
Data Flow Graph for ‘random
Data Flow Graph for ‘random
Expected Output Independent Path
Covered by Test Case
“setQueen()” method
is called & queen is
randomly placed
1
Do nothing 2
randomValue’:
random’:
12
Independent Path
Covered by Test Case
14. Data Flow Graph for ‘rowNo’:
Data Flow Graph for ‘columnNo
All du-paths:
randomValue random
1-2-3-4 2-3-4-5
2-3-4-5
’:
columnNo’:
random rowNo columnNo
5-6 5-6-7-8 6-7
5
13
columnNo
7-8