如何在 IntelliJ IDEA 中设置 JUnit 测试框架?
How to setup JUnit testing framework in IntelliJ IDEA?
我开始阅读 Kent Beck 撰写的《示例测试驱动开发》一书。他提供的示例在 Java 中,他使用 JUnit 测试框架。我决定继续阅读这本书并在 Kent 之后复习以更好地学习 TDD。
所以我安装了 IntelliJ Idea 并为第一个示例创建了空项目:
然后我去 google 了解如何设置 JUnit 并卡住了。在里面
Prepare For Testing 文章中的手动添加测试
他们告诉我的图书馆部分:
Follow these steps to add a library if you're building your project
with the native IntelliJ IDEA builder:
From the main menu, select File | Project Structure (Ctrl+Alt+Shift+S)
or click the Project Structure button on the toolbar.
Under Project Settings, select Libraries and click the New Project
Library + button | From Maven.
In the dialog that opens, specify the necessary library artifact, for
example: org.junit.jupiter:junit-jupiter:5.4.2 or
org.testng:testng:6.14.3.
Apply the changes and close the dialog.
我卡在“在项目设置下,select 库并单击新建项目库 + 按钮 | 来自 Maven”。我没有任何 Maven 按钮。当我按下 + 按钮时,它会打开本地资源管理器:
在 google 中找不到关于此问题的任何内容,每个人都只是建议“只需从 Maven 安装 JUnit”。
那么如何在 IntelliJ IDEA 中设置 JUnit?
我的问题是我创建了一个空项目,它不是 Java 项目。在我下载并安装 JDK 之后:
然后用这个 JDK 创建了 Java 项目,当我按下加号按钮时,Maven 出现了:
我成功安装了 JUnit。
我开始阅读 Kent Beck 撰写的《示例测试驱动开发》一书。他提供的示例在 Java 中,他使用 JUnit 测试框架。我决定继续阅读这本书并在 Kent 之后复习以更好地学习 TDD。
所以我安装了 IntelliJ Idea 并为第一个示例创建了空项目:
然后我去 google 了解如何设置 JUnit 并卡住了。在里面 Prepare For Testing 文章中的手动添加测试 他们告诉我的图书馆部分:
Follow these steps to add a library if you're building your project with the native IntelliJ IDEA builder:
From the main menu, select File | Project Structure (Ctrl+Alt+Shift+S) or click the Project Structure button on the toolbar.
Under Project Settings, select Libraries and click the New Project Library + button | From Maven.
In the dialog that opens, specify the necessary library artifact, for example: org.junit.jupiter:junit-jupiter:5.4.2 or org.testng:testng:6.14.3.
Apply the changes and close the dialog.
我卡在“在项目设置下,select 库并单击新建项目库 + 按钮 | 来自 Maven”。我没有任何 Maven 按钮。当我按下 + 按钮时,它会打开本地资源管理器:
在 google 中找不到关于此问题的任何内容,每个人都只是建议“只需从 Maven 安装 JUnit”。
那么如何在 IntelliJ IDEA 中设置 JUnit?
我的问题是我创建了一个空项目,它不是 Java 项目。在我下载并安装 JDK 之后:
然后用这个 JDK 创建了 Java 项目,当我按下加号按钮时,Maven 出现了:
我成功安装了 JUnit。