 
 Компания Software Cats уже более пяти лет занимается аутстафом и аутсорсом по направлениям
Если у вас есть ИТ-проблема, оставьте ваши контакты, и мы поможем составить план ее решения.
Цвет
Материал
Размер
Красный
Шерсть
S
Желтый
Хлопок
M
Синий
Шелк
L
 
 public class StatementCoverageExample {
   public void exampleMethod(int a) {
       if (a > 10) {
           System.out.println("A is greater than 10");
       }
       System.out.println("This will always be printed");
   }
}
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class StatementCoverageExampleTest {
   @Test
   public void testStatementCoverage() {
       StatementCoverageExample example = new StatementCoverageExample();
       // Тест 1: a > 10, выполняется обе строки кода
       example.exampleMethod(15);
      // Тест 2: a <= 10, выполняется только вторая строка кода
       example.exampleMethod(5);
   }
}public class BranchCoverageExample {
   public void exampleMethod(int a) {
       if (a > 10) {
           System.out.println("A is greater than 10");
       } else {
           System.out.println("A is 10 or less");
       }
   }
}import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class BranchCoverageExampleTest {
   @Test
   public void testBranchCoverage() {
       BranchCoverageExample example = new BranchCoverageExample();
       // Тест 1: a > 10, условие if выполнится
       example.exampleMethod(15);
       // Тест 2: a <= 10, условие else выполнится
       example.exampleMethod(5);
   }
}public class ConditionCoverageExample {
   public void exampleMethod(int a, int b) {
       if (a > 10 && b < 5) {
           System.out.println("A is greater than 10 and B is less than 5");
       } else {
           System.out.println("Condition not met");
       }
   }
}import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ConditionCoverageExampleTest {
   @Test
   public void testConditionCoverage() {
       ConditionCoverageExample example = new ConditionCoverageExample();
       // Тест 1: a > 10, b < 5 (оба условия истинны)
       example.exampleMethod(15, 3);
       // Тест 2: a <= 10, b < 5 (условие a ложное)
       example.exampleMethod(5, 3);
       // Тест 3: a > 10, b >= 5 (условие b ложное)
       example.exampleMethod(15, 6);
   }
} 
 