samedi 20 juin 2020

Java test fail : org.junit.ComparisonFailure

Please i need a help for this, there is no error on my code but the compiler show me an org.junit.ComparisonFailure error

at org.junit.Assert.assertEquals(Assert.java:115)
at tests.HomeworkTests.test_sum(HomeworkTests.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)

My java code is very simple :

import java.util.Scanner;
public class Sum{

     public static void main(String []args){
        Scanner scan = new Scanner(System.in);
        System.out.println("Please, enter the first number");
        int nb1 = scan.nextInt();
        System.out.println("Please, enter the second number");
        int nb2 = scan.nextInt();
        System.out.println("the result is : "+(nb1+nb2));
     }
}

Aucun commentaire:

Enregistrer un commentaire