“未找到测试".与Junit 5和IntelliJ [英] "No tests were found" with Junit 5 and IntelliJ

查看:166
本文介绍了“未找到测试".与Junit 5和IntelliJ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问与答(Q& A-Style)问题,因为现有问题与我在此处所做的简单错字不符:

目标

  • 使用UI通过IntelliJ IDE执行简单的JUnit测试(右键单击:运行测试)

问题

  • IntelliJ告知未找到测试"

代码

import org.junit.jupiter.api.Test;

public class Test {
    @Test
    private void testAMethod() { (...) }
}

推荐答案

更改为

public void testAMethod() { (...) }

根据Junit5文档

不需要测试类,测试方法和生命周期方法 是公开的,但一定不能是私有的.

Test classes, test methods, and lifecycle methods are not required to be public, but they must not be private.

https://junit.org/junit5/docs/current/user-guide /

这篇关于“未找到测试".与Junit 5和IntelliJ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆