java - getEnclosureMethod 返回 NullPointerException
问题描述
在 TestNG 测试方法中,我使用 this.getClass().getEnclosureMethod().getName() 来获取当前方法名称,但它给出了 java.lang.NullPointerException 的失败异常
我不确定,会有什么问题?
Assert.assertEquals(this.getClass().getEnclosingMethod().getName(), testcaseName);
解决方案
推荐阅读
- java - 在对象的帮助下打印一个方法(在java中运行时动态创建)
- java - tmp下的spring boot spring.log
- android - aSyncTask 只运行一次
- typescript - 如何突出显示输入的文本?
- awk - 为什么 '-1' 在 awk 中不起作用,但 '(-1)' 起作用?
- windows - 如何更改 Team Foundation Server 2018 中的控制源
- c# - 在 C# 中构建基于时间的异步服务的好方法
- c# - QnAMakerDialog - 使用元数据
- c# - .NET Core 2.x 如何获取当前活动的本地网络 IPv4 地址?
- javascript - react中基于props名称的动态导入