TestNG – 如何将测试组存储和检索为对象

huangapple go评论66阅读模式
英文:

TestNG - How to store and retrieve groups as an object

问题

我想知道是否有一种方法可以让我简单地将组列表存储在单独的基类中并在需要时调用

例如
```python
@Test(groups = {"IT", "IE", "GG", "JE", "IM", "GF", "GP", "MQ", "BL", "MF", "NC", "WF", "BE", "DK", "FI", "IS", "LU", "SE", "PT"})

我想将此列表包装为一个对象,以便于调用,使测试看起来更整洁。

期望的结果:

@Test(groups = "proxyRegions")
英文:

I'm curious if there is an approach that allows me to simply store the list of groups in a separate base class and call when needed?

For example:

@Test(groups = {"IT", "IE", "GG", "JE", "IM", "GF", "GP", "MQ", "BL", "MF", "NC", "WF", "BE", "DK", "FI", "IS", "LU", "SE", "PT"})

I'd like to wrap this list as an object to simply call so the test looks clean

Desired outcome:

@Test(groups = "proxyRegions")

答案1

得分: 1

这是不可能的。无法在运行时评估注解值。作为替代方案,您可以构建一个proxyRegions 的组,正如您所提到的,因此您的测试将对所有这些组运行。

英文:

It is not possible. Annotation value cannot be evaluated in runtime. As the alternative you can build a group proxyRegions of groups you have mentioned hence your test would run for all of them.

huangapple
  • 本文由 发表于 2020年9月3日 00:02:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/63709273.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定