【问题标题】:The method multiply(int, int) is undefined for the type Junit对于 Junit 类型,方法 multiply(int, int) 未定义
【发布时间】:2019-10-11 16:50:35
【问题描述】:

我在 Eclipse 中为 Junit 测试键入了一个简单的程序,但它显示错误:“方法 multiply(int, int) 未定义为 Junit 类型”。 封装测试;

import static org.junit.Assert.*;
import org.junit.Test;
class MultiplyTest {

  @Test
  void testMultiply() {
    Junit test=new Junit();
    int result = test.multiply(3,4);
    assertEquals(12,result);
  }
}

【问题讨论】:

  • Junit 的 FQCL 是什么?这是您创建的课程吗?如果是这样,请编辑您的问题以包含其代码。
  • Junit 必须是你的类之一,它没有定义乘法方法(int, int) 方法。 JUnit Testframework 中没有 Junit 类。很可能你会在你的包```test````中找到这个类
  • 请在您的问题中也发布 Junit 课程。

标签: java eclipse methods junit undefined


【解决方案1】:

您是否在 MultiplyTest 类中为 Junit 类编写了导入? Junit 类的包名是什么?我认为@Test 注释方法应该是公开的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    相关资源
    最近更新 更多