更新时间:2022-06-12 08:33:11
@Dennis Roberts:您说得对:我的测试类位于 src/main/java.此外,JUnit 的 POM 中范围"元素的值是测试",尽管它应该是这样.问题是我在 Eclipse 中创建测试类时很草率,导致它被创建在 src/main/java 的 src/test/java 中.在运行mvn eclipse:eclipse"后,这在 Eclipse 的项目资源管理器视图中变得更容易看到,但是您的评论让我首先看到它.谢谢.
@Dennis Roberts: You were absolutely right: My test class was located in src/main/java. Also the value of the "scope" element in the POM for JUnit was "test", although that is how it is supposed to be. The problem was that I had been sloppy when creating the test class in Eclipse, resulting in it being created in src/main/java insted of src/test/java. This became easier to see in Eclipse's Project Explorer view after running "mvn eclipse:eclipse", but your comment was what made me see it first. Thanks.