JUnit 5 @Nested注释的目的是什么? [英] What's the purpose of the JUnit 5 @Nested annotation

查看:2158
本文介绍了JUnit 5 @Nested注释的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JUnit 5中,有一个新的注释: @Nested

In JUnit 5, there is a new annotation: @Nested.

我理解它是如何工作的,我理解为什么我们使用嵌套类,
我只是不明白为什么我们需要在测试中使用嵌套测试类。

I understand how it work, I understand why we use nested class, I just don't understand why we need to have nested test class in our test.

推荐答案

@Nested 注释允许你有一个内部类,它本质上是一个测试类,允许你在下面组合几个测试类相同的父级(具有相同的初始化)。

The @Nested annotation allows you to have an inner class that's essentially a test class, allowing you to group several test classes under the same parent (with the same initialization).

这篇关于JUnit 5 @Nested注释的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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