英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论