hi there I am trying to test my code java code with JUnit test case
but there is a problem with the tester I don't know what it is, happy to get from your review and guides
here is the code>>
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class Ex2_Test {
static double[] po1={2,0,3, -1,0},
po2 = {0.1,0,1, 0.1,3};
static final double EPS = 0.0001;
@Test
void testF() {
double fx0 = Ex2.f(po1, 0);
double fx1 = Ex2.f(po1, 1);
double fx2 = Ex2.f(po1, 2);
assertEquals()
assertEquals(fx0,2);
assertEquals(fx1,4);
assertEquals(fx2,6);
}
@Test
void testRoot() {
double x12 = Ex2.root(po1, 0, 10, EPS);
assertEquals(x12, 3.1958, 0.001);
}
@Test
void testDerivativeArrayDoubleArray() {
double[] p = {1,2,3}; // 3X^2+2x+1
double[] dp1 = {2,6}; // 6x+2
double[] dp2 = Ex2.derivative(p);
assertEquals(dp1[0], dp2[0],EPS);
assertEquals(dp1[1], dp2[1],EPS);
assertEquals(dp1.length, dp2.length);
}
}
and here is the errors messages>>
The method assertEquals() is undefined for the type Ex2_Test The import org.junit cannot be resolved
The method assertEquals(double, int) is undefined for the type Ex2_Test
The method assertEquals(double, int) is undefined for the type Ex2_Test
Test cannot be resolved to a type
Test cannot be resolved to a type
The method assertEquals(double, double, double) is undefined for the type Ex2_Test
The method assertEquals(int, int) is undefined for the type Ex2_Test
The method assertEquals(double, double, double) is undefined for the type Ex2_Test
please check the image here>>
Aucun commentaire:
Enregistrer un commentaire