![8af79cfbc8e826bb7aed543dbdeffb70.png](https://i-blog.csdnimg.cn/blog_migrate/13919ec809e500bce9ccbc4365560cbe.jpeg)
这里分享一个 IntelliJ IDEA 运行 @Test 测试方法失败的问题以及解决方法。
测试类如下:
public class DaoTest {
@Test
public void register() {
String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
User user = new User("renda", "123456", "123456789456", date);
System.out.println("注册成功");
}
}
运行报错:
Error:Internal error: (java.lang.UnsupportedOperationException) empty.min
java.lang.UnsupportedOperationException: empty.min
at scala.collection.TraversableOnce.min(TraversableOnce.scala:225)
at scala.collection.TraversableOnce.min$(TraversableOnce.scala:223)
at scala.collection.AbstractTraversable.min(Traversable.scala:108)
at org.jetbrains.jps.incremental.scala.ScalaCompilerReferenceIndexBuilder.getTargetTimestamps(ScalaCompilerReferenceIndexBuilder.scala:53)
at org.jetbrains.jps.incremental.scala.ScalaCompilerReferenceIndexBuilder.getAllClassesInfo(ScalaCompilerReferenceIndexBuilder.scala:99)
at org.jetbrains.jps.incremental.scala.ScalaCompilerReferenceIndexBuilder.buildFinished(ScalaCompilerReferenceIndexBuilder.scala:33)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:468)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:190)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:297)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:130)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
执行 maven clean 之后再运行测试方法会报错:
no tests were found
后来发现是项目的 .idea 文件夹和 .iml 文件因为路径不匹配引起的问题,于是删掉 .idea 文件夹和 .iml 文件,重新用 IDEA 打开项目,重新生成 .idea 文件夹和 .iml 文件,测试方法可以正常运行。
想了解更多,欢迎关注我的微信公众号:Renda_Zhang