Skip to content

fsoupimenta/unit-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit test 🧪

Sonar Coverage

Study of unit testing in Java, based on McCabe's cyclomatic complexity for the choice of test cases, as well as the use of the border testing strategy.

Classes

To carry out the study, two basic classes were used, one with the object of calculating a person's average body mass index and returning their status in a String. The other has the objective of applying an aliquot to the value of a product, according to the rate of each federative unit in Brazil, and returning the new value as a Double.

Results Table

Condition Female BMI Male BMI
Under weight < 19.1 < 20.7
Normal weight <= 19.1 < 25.8 <= 20.7 < 26.4
Marginally overweight <= 25.8 < 27.3 <= 26.4 < 27.8
Over ideal weight <= 27.3 < 32.3 <= 27.8 < 31.1
Obese >= 32.3 >= 31.1

Cycle Complexity Graph

        if (this.getSex() == 'F'){ // 1
            if (bodyMassIndexValue < 19.1){ // 2
                bodyMassIndexResult = "Under weight"; // 3
            }
            else if (bodyMassIndexValue < 25.8){ // 4
                bodyMassIndexResult = "Normal weight"; // 5
            }
            else if (bodyMassIndexValue < 27.3){ // 6
                bodyMassIndexResult = "Marginally overweight"; // 7
            } 
            else if (bodyMassIndexValue < 32.3){ // 8
                bodyMassIndexResult = "Over ideal weight"; // 9
            }
            else { 
                bodyMassIndexResult = "Obese"; // 10
            }
        }
        else{ 
            if (bodyMassIndexValue < 20.7){ // 11
                bodyMassIndexResult = "Under weight"; // 12
            }
            else if (bodyMassIndexValue < 26.4){ // 13
                bodyMassIndexResult = "Normal weight"; // 14
            }
            else if (bodyMassIndexValue < 27.8){ // 15
                bodyMassIndexResult = "Marginally overweight"; // 16
            }
            else if (bodyMassIndexValue < 31.1){ // 17
                bodyMassIndexResult = "Over ideal weight"; // 18
            }
            else { 
                bodyMassIndexResult = "Obese"; // 19
            }
        }
        return bodyMassIndexResult; // 20

Results Table

Federation Units Product Value Aliquot Tax Final Value
AC - AL - ES - GO - MT - MS - PA - RR - SC 100.00 17% 117.00
AM - AP - BA - CE - DF - MA - MG - PB - PR - PE - PI - RN - RS - RJ - SP - SE - TO 100.00 18% 118.00
RO 100.00 17.5% 117.50

Cycle Complexity Graph

        if ("AC".equals(this.getFederationUnit()) /* 1 */ || "AL".equals(this.getFederationUnit()) /* 3 */ ||
                "ES".equals(this.getFederationUnit()) /* 4 */ || "GO".equals(this.getFederationUnit()) /* 5 */ ||
                "MT".equals(this.getFederationUnit()) /* 6 */ || "MS".equals(this.getFederationUnit()) /* 7 */ ||
                "PA".equals(this.getFederationUnit()) /* 8 */ || "RR".equals(this.getFederationUnit()) /* 9 */ ||
                "SC".equals(this.getFederationUnit()) /* 10 */ ) {
            productValueWithAliquot = this.getProductValue() + (this.getProductValue() * 0.17); // 2
        }
        else if ("AM".equals(this.getFederationUnit()) /* 11 */ || "AP".equals(this.getFederationUnit()) /* 13 */ ||
                "BA".equals(this.getFederationUnit()) /* 14 */ || "CE".equals(this.getFederationUnit()) /* 15 */ ||
                "DF".equals(this.getFederationUnit()) /* 16 */ || "MA".equals(this.getFederationUnit()) /* 17 */ ||
                "MG".equals(this.getFederationUnit()) /* 18 */ || "PB".equals(this.getFederationUnit()) /* 19 */ ||
                "PR".equals(this.getFederationUnit()) /* 20 */ || "PE".equals(this.getFederationUnit()) /* 21 */ ||
                "PI".equals(this.getFederationUnit()) /* 22 */ || "RN".equals(this.getFederationUnit()) /* 23 */ ||
                "RS".equals(this.getFederationUnit()) /* 24 */ || "RJ".equals(this.getFederationUnit()) /* 25 */ ||
                "SP".equals(this.getFederationUnit()) /* 26 */ || "SE".equals(this.getFederationUnit()) /* 27 */ ||
                "TO".equals(this.getFederationUnit()) /* 28 */ ){
            productValueWithAliquot = this.getProductValue() + (this.getProductValue() * 0.18); // 12
        }
        else {
            productValueWithAliquot = this.getProductValue() + (this.getProductValue() * 0.175); // 29
        }
        return productValueWithAliquot; // 30

About

Study of software unit testing using a body mass index system in Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages