JUnit assertEquals失败但显示相同的Expected和Actual结果

时间:2017-04-26 17:14:56

标签: java junit assert

我做了一个assertEqual测试但它失败了,即使它显示预期和实际结果是相同的。我查了一下,我看到你需要检查被比较的对象是否属于同一类型,在这种情况下,它们仍然失败,这就是测试:

  public void testConstructRayThroughPixel() {
    System.out.println("constructRayThroughPixel");
    int Nx = 3;
    int Ny = 3;
    double x = 3.0;
    double y = 3.0;
    double screenDistance = 100.0;
    double screenWidth = 150.0;
    double screenHeight = 150.0;
    Camera instance = new Camera();
    Ray expResult = new Ray(new Point3D(new Coordinate(50),new Coordinate(-50),new Coordinate(-100)),new Vector(new Point3D(new Coordinate(50),new Coordinate(-50),new Coordinate(-100))));
    Ray result = instance.constructRayThroughPixel(Nx, Ny, x, y, screenDistance, screenWidth, screenHeight);
    assertEquals(expResult, result);

}

这是结果(上传图片): assertEqual result

对于在这里编辑的人来说,我不知道它与double类型有什么关系,这是" Ray" ...

的两个对象之间的理解。

0 个答案:

没有答案