简体   繁体   English

与DataProvider一起使用的TestNG Factory和@BeforeClass或@BeforeSuite

[英]TestNG Factory and @BeforeClass or @BeforeSuite used with DataProvider

when using constructor Factory together with DataProvider, the dataprovider is always run before @BeforeSuite. 当将构造函数Factory与DataProvider一起使用时,dataprovider始终在@BeforeSuite之前运行。

Anybody know what is going on ? 有人知道发生了什么吗? It is quite useless because I can't imagine that I would initialize stuff in one of @DataProviders... 它非常没用,因为我无法想象我会在@DataProviders之一中初始化东西。

Also if II use a DataProvider that makes constructor of @Factory run 2 times, then the test class is run 2 times with @BeforeClass and then it runs again without @BeforeClass.. The third cycle shouldn't exist, because DataProvider returns only 2 values... 同样,如果II使用的DataProvider使@Factory的构造函数运行2次,则测试类使用@BeforeClass运行2次,然后在没有@BeforeClass的情况下再次运行。第三个周期不应该存在,因为DataProvider仅返回2价值观...

It is by design like this. 就是这样设计的。 You just need to avoid using anything that is being initialized in @BeforeSuite method in your DataProviders or initialize it statically. 您只需要避免在DataProviders中使用@BeforeSuite方法中正在初始化的任何内容,或者静态地对其进行初始化。

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

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