Wprowadzenie_do_testowania/Testy po testowaniu mutacyjnym/BMITest.java
2022-06-20 14:04:23 +02:00

372 lines
8.5 KiB
Java

package com.epam.bootcamp.bmi_calculator;
import static org.junit.Assert.*;
import org.junit.*;
import org.junit.rules.ExpectedException;
import com.epam.bootcamp.bmi_calculator.interfacesImplements.MetricBMI;
public class BMITest {
App app;
/*@Test
public void GuessTheUnitsTest1() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(1.7,50.0);
assertEquals(gtu.getUnitType(),"metric");
}
@Test
public void GuessTheUnitsTest2() throws Exception{
}*/
@Before
public void setup(){
app = new App();
}
@Test
public void BMITest1() throws Exception{
app.setHeight(1.7);
app.setWeight(50);
assertEquals(app.calculateBMI(),17.3,1);
assertEquals(app.bmiResult(),"Thinness");
}
@Test
public void BMITest2() throws Exception{
try{
app.setHeight(0);
app.setWeight(50.0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest39() throws Exception{
try{
app.setHeight(0.001);
app.setWeight(150.0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest40() throws Exception{
try{
app.setHeight(0.00);
app.setWeight(150.0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest12() throws Exception{
try{
app.setHeight(-0.01);
app.setWeight(50.0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest13() throws Exception{
try{
app.setHeight(-1);
app.setWeight(50.0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest14() throws Exception{
try{
app.setHeight(-11);
app.setWeight(50.0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest3() throws Exception{
try{
app.setHeight(1);
app.setWeight(-3);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest37() throws Exception{
try{
app.setHeight(0);
app.setWeight(0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest38() throws Exception{
try{
app.setHeight(0);
app.setWeight(10);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest10() throws Exception{
try{
app.setHeight(1);
app.setWeight(-1);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest31() throws Exception{
try{
app.setHeight(0);
app.setWeight(1);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest32() throws Exception{
try{
app.setHeight(1);
app.setWeight(0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest33() throws Exception{
try{
app.setHeight(188);
app.setWeight(0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest34() throws Exception{
try{
app.setHeight(188);
app.setWeight(0.0);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest35() throws Exception{
try{
app.setHeight(0);
app.setWeight(123);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest36() throws Exception{
try{
app.setHeight(0.0);
app.setWeight(76);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height is equals or less than zero.");
}
}
@Test
public void BMITest11() throws Exception{
try{
app.setHeight(1);
app.setWeight(-300000);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest4() throws Exception{
try{
app.setHeight(170);
app.setWeight(1764);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height and weight is in different metric.");
}
}
@Test
public void BMITest18() throws Exception{
try{
app.setHeight(5.9);
app.setWeight(60);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Height and weight is in different metric.");
}
}
@Test
public void BMITest19() throws Exception{
try{
app.setHeight(5.1);
app.setWeight(-60);
app.calculateBMI();
}catch(Exception e){
assertEquals(e.getMessage(),"Weight is equals or less than zero.");
}
}
@Test
public void BMITest5() throws Exception{
app.setHeight(170);
app.setWeight(50.0);
assertEquals(app.calculateBMI(),17.3,1);
assertEquals(app.bmiResult(),"Thinness");
}
@Test
public void BMITest6() throws Exception{
app.setHeight(5.58);
app.setWeight(1764);
assertEquals(app.calculateBMI(),17.3,1);
assertEquals(app.bmiResult(),"Thinness");
}
@Test
public void BMITest7() throws Exception{
app.setHeight(86.7);
app.setWeight(6349.3);
assertEquals(app.calculateBMI(),37.19,0.5);
assertEquals(app.bmiResult(),"Heavily overweight");
}
@Test
public void BMITest8() throws Exception{
app.setHeight(6.56);
app.setWeight(220.47);
assertEquals(app.calculateBMI(),25,0.5);
assertEquals(app.bmiResult(),"Overweight");
}
@Test
public void BMITest15() throws Exception{
app.setHeight(6.56);
app.setWeight(2220.47);
assertEquals(app.calculateBMI(),15.743818755222017,0.5);
assertEquals(app.bmiResult(),"Thinness");
}
@Test
public void BMITest16() throws Exception{
app.setHeight(1.56);
app.setWeight(220.47);
assertEquals(app.calculateBMI(),90.59418145956607,0.5);
assertEquals(app.bmiResult(),"Heavily overweight");
}
@Test
public void BMITest9() throws Exception{
app.setHeight(200);
app.setWeight(80);
assertEquals(app.calculateBMI(),20,0.0);
assertEquals(app.bmiResult(),"Normal");
}
@Test
public void BMITest17() throws Exception{
app.setHeight(210);
app.setWeight(83);
assertEquals(app.calculateBMI(),18.820861678004533,0.0);
assertEquals(app.bmiResult(),"Normal");
}
@Test
public void BMITest20() throws Exception{
app.setHeight(5.58);
app.setWeight(1788);
assertEquals(app.calculateBMI(),18.4,1);
assertEquals(app.bmiResult(),"Thinness");
}
@Test
public void BMITest28() throws Exception{
app.setHeight(180);
app.setWeight(59.98);
assertEquals(app.calculateBMI(),18.5,1);
assertEquals(app.bmiResult(),"Normal");
}
@Test
public void BMITest21() throws Exception{
app.setHeight(180);
app.setWeight(59.5);
assertEquals(app.calculateBMI(),18.3,1);
assertEquals(app.bmiResult(),"Thinness");
}
@Test
public void BMITest27() throws Exception{
app.setHeight(180);
app.setWeight(60.5);
assertEquals(app.calculateBMI(),18.3,1);
assertEquals(app.bmiResult(),"Normal");
}
@Test
public void BMITest22() throws Exception{
app.setHeight(180);
app.setWeight(80.3);
assertEquals(app.calculateBMI(),24.78,1);
assertEquals(app.bmiResult(),"Normal");
}
@Test
public void BMITest29() throws Exception{
app.setHeight(180);
app.setWeight(80.6);
assertEquals(app.calculateBMI(),24.9,1);
assertEquals(app.bmiResult(),"Normal");
}
@Test
public void BMITest25() throws Exception{
app.setHeight(180);
app.setWeight(81);
assertEquals(app.calculateBMI(),25,1);
assertEquals(app.bmiResult(),"Overweight");
}
@Test
public void BMITest23() throws Exception{
app.setHeight(180);
app.setWeight(96);
assertEquals(app.calculateBMI(),29.6,1);
assertEquals(app.bmiResult(),"Overweight");
}
@Test
public void BMITest30() throws Exception{
app.setHeight(180);
app.setWeight(96.8);
assertEquals(app.calculateBMI(),29.9,1);
assertEquals(app.bmiResult(),"Overweight");
}
@Test
public void BMITest24() throws Exception{
app.setHeight(180);
app.setWeight(99);
assertEquals(app.calculateBMI(),30.6,1);
assertEquals(app.bmiResult(),"Heavily overweight");
}
}