idea中测试Demo@Test报红且Alt+Enter无import class
- 首先检查pom.xml文件中是否配置了junit的依赖
- 若已经配置检查版本是否过期(据说还有可能是因为JUnit 版本低于4.12)
在该网址搜索Maven可以查可用版本号;junit junit 4.13 test - 导入后重新加载Maven项目
- 鼠标在@Test上,Alt+Enter,选择import class
import org.junit.Test; - 完成!
junit junit 4.13 test import org.junit.Test;