HW#_YOUR-Name#

docx

School

Chuka University College *

*We aren’t endorsed by this school

Course

MISC

Subject

Computer Science

Date

Nov 24, 2024

Type

docx

Pages

14

Uploaded by boris2

Report
Software Testing, Verification, Validation and QA. [Student Name] [Course Code] [Institution Affiliation] [Date]
Design, implement, and run PC (Predicate Coverage), CC (Clause Coverage) and CACC (Correlated Active Clause Coverage) tests for the method turnHeaterOn in class Thermostat.java Question 1. (5 points) List all predicates in the method. How many have one clause, two clauses, three clauses, and more than three? From the turnHeaterOn method in Thermostat.java: Predicate 1 contains two clauses: curTemp < dTemp - thresholdDiff. override && curTemp < overTemp - thresholdDiff. Predicate 2 doesn't have explicit clauses but represents the opposite condition when Predicate 1 is not satisfied. Therefore, for the given turnHeaterOn method in the Thermostat class: 1 predicate has two clauses. 1 predicate has no explicit clauses but represents the else condition. There are no predicates with three or more clauses.
Figure 1: turnHeaterOn Method. Question 2. For each predicate, write the truth table and choose rows from the truth tables that satisfy PC. a. (10 points) You must submit the truth tables and clearly mark which rows will be used. These are your abstract tests. I'll represent the predicate and create the truth table rows for the combination of its clauses in order to build the truth table for the predicate in the turnHeaterOn method. Let's examine the turnHeaterOn method's first predicate:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
All potential pairings of truth values for the clauses in Predicate 1 will be represented by the truth table. For each clause, we'll use 'T' for true and 'F' for false, and we'll assess the resulting predicate. The truth table for Predicate 1 is as follows: Clause 1 Clause 2 Predicate Results T T True T F False F T False F F False We will select rows that cover each of the possible outcomes of the clauses in order to identify the rows that satisfy Predicate Coverage (PC). At least one row that proves the predicate to be true and one row that proves it to be false are required for Predicate Coverage (PC). The rows that satisfy PC in this instance are: Row 1: T for Clause 1 and T for Clause 2 (True) Row 4: False (Clause 1 = F, Clause 2 = F) Because they cover both the true and false outcomes of the predicate, these chosen rows satisfy the predicate coverage requirement. b. (5 points) For each abstract test, create input values that satisfy the truth assignments and that reach the predicate. We need to construct scenarios that match the truth values in the chosen rows of the truth table for Predicate 1 in order to produce input values that satisfy the truth assignments and cover the abstract tests. In order to get the predicate for the chosen rows, let's generate input values for the abstract tests: Abstract Test 1 (Row 1 - Predicate Result: True) Input Values: curTemp: a value less than dTemp - thresholdDiff override: true overTemp: a value less than curTemp + thresholdDiff timeSinceLastRun: a value greater than minLag Abstract Test 2 (Row 4 - Predicate Result: False)
Input Values: curTemp: a value greater than or equal to dTemp - thresholdDiff override: false or true (as this clause does not directly contribute to the predicate being false) overTemp: a value greater than or equal to curTemp + thresholdDiff timeSinceLastRun: a value less than or equal to minLag These input value scenarios are intended to complete the truth assignments and reach the predicate for the rows in the truth table that have been chosen. c. (10 points) Implement each test in Junit file “ThermostatTest_PC.java”. Include comments that state which predicate and which truth assignment (row in the truth table) is being implemented. We'll write test methods that correspond to the abstract tests produced from the truth table to implement the abstract tests for Predicate Coverage (PC) in a JUnit file named ThermostatTest_PC.java. Here is a Java implementation of the two abstract tests:
This shows how to write JUnit tests for abstract tests generated from Predicate 1's truth table. Adjust the input values for each abstract test based on the scenario you've created. If an argument to turnHeaterOn is required, replace ProgrammedSettings with the appropriate instance. This JUnit test file can be used to check the turnHeaterOn method's functionality for certain input circumstances based on the truth table's selected entries. d. (5 points) Run your tests. Below are the test results of the ThermostatTest_PC.java. Question 3: For each predicate, write the truth table and choose rows from the truth tables that satisfy CC. a. (10 points) You must submit the truth tables and clearly mark which rows will be used. These are your abstract tests. To meet Clause Coverage (CC) in the turnHeaterOn method, abstract tests that cover each clause separately and combinations of clauses that verify all portions of the predicate are exercised are required. The truth tables for each predicate and select rows that fulfill Clause Coverage are shown below. Predicate 1: Predicate 1 Truth Table:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Clause 1 Clause 2 T T T F F T F F For Clause Coverage, There is a need to choose rows that cover each individual clause as well as clause combinations. Predicate 1 Abstract Tests. i. Abstract Test 1 (Covering Clause 1): Row 1: Clause 1 = T, Clause 2 = T ii. Abstract Test 2 (Covering Clause 2): Row 2: Clause 1 = T, Clause 2 = F Row 3: Clause 1 = F, Clause 2 = T iii. Abstract Test 3 (Combination of Clauses): Row 4: Clause 1 = F, Clause 2 = F These abstract tests are intended to cover each individual clause as well as clause combinations in order to satisfy Clause Coverage for Predicate 1. b. (5 points) For each abstract test, create input values that satisfy the truth assignments and that reach the predicate. To generate input values for each abstract test that fulfill the truth assignments and reach the predicate for Predicate 1, scenarios based on the truth table's selected rows are used: i. Abstract Test 1 (Row 1 - Clause 1 = T, Clause 2 = T): Input Values: curTemp: a value less than dTemp - thresholdDiff dTemp: a value greater than thresholdDiff thresholdDiff: a positive value override: true overTemp: a value less than curTemp + thresholdDiff timeSinceLastRun: a value greater than minLag
ii. Abstract Test 2 (Row 2 - Clause 1 = T, Clause 2 = F): Input Values: curTemp: a value less than dTemp - thresholdDiff dTemp: a value greater than thresholdDiff thresholdDiff: a positive value override: false overTemp: a value greater than or equal to curTemp + thresholdDiff timeSinceLastRun: any value iii. Abstract Test 3 (Row 3 - Clause 1 = F, Clause 2 = T): Input Values: curTemp: a value greater than or equal to dTemp - thresholdDiff dTemp: any value thresholdDiff: any value override: true overTemp: a value less than curTemp + thresholdDiff timeSinceLastRun: a value greater than minLag iv. Abstract Test 4 (Row 4 - Clause 1 = F, Clause 2 = F): Input Values: curTemp: a value greater than or equal to dTemp - thresholdDiff dTemp: any value thresholdDiff: any value override: false overTemp: a value greater than or equal to curTemp + thresholdDiff timeSinceLastRun: any value These input scenarios are intended to satisfy the truth assignments for each abstract test, guaranteeing that each phrase and combination of clauses is used to obtain Predicate 1. c. (10 points) Implement each test in Junit file “ThermostatTest_CC.java”. Include comments that state which predicate and which truth assignment (row in the truth table) is being implemented. This is the implementation test methods that correspond to each abstract test obtained from Predicate 1's truth table in order to implement the abstract tests for Clause Coverage (CC) in a JUnit file named ThermostatTest_CC.java.
D. (5 points) Run your tests. Below is the output of ThermostatTest_CC.java
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Question 4: For each predicate, write the truth table and choose rows from the truth tables that satisfy CACC. a. (10 points) You must submit the truth tables and clearly mark which rows will be used. These are your abstract tests. To accomplish Correlated Active Clause Coverage (CACC) in the turnHeaterOn method, there is a need to establish truth tables and choose rows that ensure each individual clause influences the overall predicate outcome. Predicate 1: Predicate 1 Truth Table. Clause 1 Clause 2 T T T F F T F F
For Correlated Active Clause Coverage (CACC), we'll select rows that ensure each clause affects the overall predicate result in correlation with the other clauses. Predicate 1 Abstract Tests: i. Abstract Test 1 (Row 1 - Clause 1 = T, Clause 2 = T): This test satisfies both sentences at the same time, proving the predicate true. ii. Abstract Test 2 (Row 2 - Clause 1 = T, Clause 2 = F): This test satisfies Clause 1 but not Clause 2, hence the predicate is false. iii. Abstract Test 3 (Row 3 - Clause 1 = F, Clause 2 = T): This test satisfies Clause 2 but not Clause 1, hence the predicate is false. iv. Abstract Test 4 (Row 4 - Clause 1 = F, Clause 2 = F): The predicate is false since neither Clause 1 nor Clause 2 are satisfied by this test. In order to meet Correlated Active Clause Coverage (CACC) requirements for Predicate 1, these abstract tests are made to make sure that every single clause has an impact on the final predicate result when joined with other clauses. b. v. Abstract Test 1 (Row 1 - Clause 1 = T, Clause 2 = T): Input Values: curTemp: any value less than dTemp - thresholdDiff dTemp: any value greater than thresholdDiff thresholdDiff: any positive value override: true overTemp: any value less than curTemp + thresholdDiff timeSinceLastRun: any value greater than minLag vi. Abstract Test 2 (Row 2 - Clause 1 = T, Clause 2 = F): Input Values: curTemp: any value less than dTemp - thresholdDiff dTemp: any value greater than thresholdDiff thresholdDiff: any positive value override: false overTemp: any value greater than or equal to curTemp + thresholdDiff timeSinceLastRun: any value
vii. Abstract Test 3 (Row 3 - Clause 1 = F, Clause 2 = T): Input Values: curTemp: any value greater than or equal to dTemp - thresholdDiff dTemp: any value thresholdDiff: any value override: true overTemp: any value less than curTemp + thresholdDiff timeSinceLastRun: any value greater than minLag viii. Abstract Test 4 (Row 4 - Clause 1 = F, Clause 2 = F): Input Values: curTemp: any value greater than or equal to dTemp - thresholdDiff dTemp: any value thresholdDiff: any value override: false overTemp: any value greater than or equal to curTemp + thresholdDiff timeSinceLastRun: any value The purpose of these input scenarios is to fulfill the truth assignments for every abstract test, guaranteeing that the truth value of every phrase contributes to the overall outcome of Predicate 1. c. (10 points) Implement each test in Junit file “ThermostatTest_CACC.java”. Include comments that state which predicate and which truth assignment (row in the truth table) is being implemented. This is the implementation of the Correlated Active Clause Coverage (CACC) abstract tests in a JUnit file called ThermostatTest_CACC.java. Each abstract test obtained from the truth table of Predicate 1 is mapped to a test method in this file.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
D. (5 points) Run your tests. Below is the Output of ThermostatTest_CACC.java code developed.