Postări

Se afișează postări din iulie, 2025

Static code analysis for CONDITION COVERAGE

  Condition coverage is a software testing metric that ensures each atomic condition in a decision (e.g., a > 0 , b == 5 ) is evaluated to both true and false at least once, regardless of the overall outcome of the full expression. It helps identify whether all logical components of a conditional statement have been tested individually. This program performs a simple static analysis by counting the number of if statements in the source file and identifying the line numbers where they appear. The goal is to help locate decision points in the code. Each if may contain one or more sub-conditions that need to be tested for condition coverage. By identifying the number and location of if statements, testers can better understand the logical complexity of the code and plan test cases to ensure adequate coverage.       Condition Coverage (%) = (Number of conditions evaluated to both true and false) / (Total number of conditions) × 100 #include <iostream> #in...

STATEMENT COVERAGE

STATEMENT COVERAGE APPLICATION - COUNTING ELSE INSTRUCTIONS  Statement Coverage is a fundamental software testing metric. It measures the percentage of executable statements in your code that are executed at least once by your test suite. Its primary goal is to ensure that every line of code that can be run has been touched by a test, helping to identify untested or "dead" code. In the following program, I tried to analyse the statement coverage by counting the else instructions - static code analyse: #include <iostream> #include <fstream> #include <string.h> using namespace std; ifstream fin ("STATEMENT COVERAGE.in"); ofstream fout ("STATEMENT COVERAGE.out"); int main() {     char linie[100];     int nrtot_else=0, nr_linie=0;     while(!fin.eof())     {         fin.getline(linie,100);         nr_linie++;         if (strstr(linie,"else")>0 && !(strstr(li...