简体   繁体   English

TestNG - 构造函数上的@Test

[英]TestNG - @Test on constructor

I don't have the newest version of TestNG, and I have option to add @Test on constructor, java docs我没有最新版本的 TestNG,我可以选择在构造函数、 java 文档上添加@Test

 @Target({METHOD, TYPE, CONSTRUCTOR}) public @interface Test {

I didn't find any clue on usage in docs or searching online我没有在文档或在线搜索中找到任何有关使用的线索

@Test Marks a class or a method as part of the test. @Test将类或方法标记为测试的一部分。

When/Why @Test can be define on constructor?何时/为什么可以在构造函数上定义@Test is it for internal purposes only?仅用于内部目的吗?

I saw that CONSTRUCTOR was removed in latest TestNG version, but I didn't find why.我看到 CONSTRUCTOR 在最新的 TestNG 版本中被删除了,但我没有找到原因。

See issue " Remove irrelevant "targets" for TestNG annotations ": The target CONSTRUCTOR had no functionality in older versions, because constructors were not seen as test methods.请参阅问题“删除与 TestNG 注释无关的“目标” :目标构造函数在旧版本中没有功能,因为构造函数不被视为测试方法。 That's why the target was removed later.这就是后来目标被移除的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM