首页 > 解决方案 > getEnclosureMethod 返回 NullPointerException

问题描述

在 TestNG 测试方法中,我使用 this.getClass().getEnclosureMethod().getName() 来获取当前方法名称,但它给出了 java.lang.NullPointerException 的失败异常

我不确定,会有什么问题?

Assert.assertEquals(this.getClass().getEnclosingMethod().getName(), testcaseName);

标签: javamethodstestngassertion

解决方案


推荐阅读