首页 > 解决方案 > 错误:类、接口或枚举预期导入

问题描述

在下面的代码中,我取消了警告,因为我将使用已弃用的 assertEquals 方法。我遇到的问题是,当我运行下面的代码时,出现错误:

MyTests.java:3:错误:类、接口或枚举预期导入 org.junit.*;

@SuppressWarnings("deprecation")

import org.junit.*;
import static org.junit.Assert.*;


public class MyTests {


}

标签: javajunit

解决方案


注释必须在类上

import org.junit.*;
import static org.junit.Assert.*;

@SuppressWarnings("deprecation")
public class MyTests {


}

但你应该避免使用不推荐使用的方法......

存在同名但签名不同的方法: assertEquals(double expected, double actual, double delta)

来源:https ://stackoverflow.com/a/33274105/5950567


推荐阅读