mercredi 30 septembre 2020

Eclipse(java testing) - terminate mutant version

I am a learner on the Coursera "Introduction to Software Testing" course. I am submitting my unit test assignment but the grader output on the Coursera site shows me this:

mutant1: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant10: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant15: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant18: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant2: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant21: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant23: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant25: -0.020833333333333332 *** Learner did not properly terminate mutant version! *** mutant3: -0.020833333333333332 *** Learner did not properly terminate mutant version! ***

Kindly help! I have to submit the assignment to get a certificate.

// Demo.java

import java.util.Scanner;

public class Demo {

    public static void main(String[] args) {
        // Reading from System.in
        Scanner reader = new Scanner(System.in);  
        
        System.out.println("Enter side 1: ");
        // Scans the next token of the input as an int.
        int side_1 = reader.nextInt();
        
        System.out.println("Enter side 2: ");
        // Scans the next token of the input as an int.
        int side_2 = reader.nextInt();
        
        System.out.println("Enter side 3: ");
        // Scans the next token of the input as an int.
        int side_3 = reader.nextInt();
        
        if (isTriangle(side_1, side_2, side_3)) {
            System.out.println("This is a triangle.");
        }
        else {
            System.out.println("This is not a triangle.");
        }
        
        reader.close();

    }
    
    public static boolean isTriangle(double a, double b, double c) {
        if ((a + b > c) &&
            (a + c > b) && // should be a + c > b
            (b + c > a)) {
            return true; 
        }
        return false;
    }

}

the testing code is:

import static org.junit.Assert.*;

import org.junit.Test;

public class DemoTest {

    @Test
    public void triangle_test_1() {
        assertTrue(Demo.isTriangle(3,2,4));
    }
    
    @Test
    public void triangle_test_2() {
        assertTrue(Demo.isTriangle(4,3,5));
    }
    
    @Test
    public void triangle_test_3() {
        assertTrue(Demo.isTriangle(5,3,5));
    }
    
    @Test
    public void triangle_test_4() {
        assertTrue(Demo.isTriangle(6,4,5));
    }
    
    @Test
    public void triangle_test_5() {
        assertTrue(Demo.isTriangle(7,5,6));
    }
    
    @Test
    public void triangle_test_6() {
        assertFalse(Demo.isTriangle(13,2,4));
    
    }
    
    @Test
    public void triangle_test_7() {
        assertFalse(Demo.isTriangle(4,3,15));
    }
    
    @Test
    public void triangle_test_8() {
        assertFalse(Demo.isTriangle(3,22,4));
    }
    
    @Test
    public void triangle_test_9() {
        assertFalse(Demo.isTriangle(24,2,5));
    }
    
    @Test
    public void triangle_test_10() {
        assertFalse(Demo.isTriangle(34,2,4));
    }
    
    
    @Test
    public void triangle_test_11() {
        assertFalse(Demo.isTriangle(2,10,4));
        
    }
    
    

}

Aucun commentaire:

Enregistrer un commentaire