java - maven junit 4.5 中没有 org.junit.test 包

标签 java maven junit

我有 junit 版本 4.5 的 Maven 依赖项,并且想要使用 @test 声明,但不能,因为该 Artifact 中没有 org.junit.test 包。为什么会这样以及我如何将 @test 与 Maven Artifact 一起使用?

最佳答案

完全限定的类是org.junit.Test。肯定就在那里。

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.5</version>
</dependency>

测试:

import org.junit.Assert;
import org.junit.Test;

public class ThisIsATest {

    @Test
    public void method() {
        Assert.assertTrue("OMG test!", true);
    }

}

关于java - maven junit 4.5 中没有 org.junit.test 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18609271/

相关文章:

java - 合理 `instanceof` ?将其与接口(interface)一起使用,但不与实现类型一起使用

java - 在 Weblogic 中保护 session ID Cookie 会扰乱 session 创建

java - 如何安排自动打印作业?

java - 如何将我的 Maven 项目部署为 jar 文件,该文件将使用 pom 文件获取其依赖项?

java - Maven,排除 junit 的 hamcrest 依赖

java - 运行/调试配置以红色突出显示普通应用程序的选定主类

java - 带有@SpringBootConfiguration 的 Spring Boot 多模块应用程序

android - 如何将 android 库 (apklibs) 与 maven 和 eclipse 一起使用?

java - 在 Maven 项目中将 stub 类放在哪里

java - 我需要测试 void、任何 GUI 处理程序或网络操作方法吗?