单元测试框架-TestNG使用可配置的值定义threadPoolSize [英] Unit test framework - TestNG using configurable value to define threadPoolSize

查看:557
本文介绍了单元测试框架-TestNG使用可配置的值定义threadPoolSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在挖掘 TestNG 框架.

我正在使用注释在测试用例中配置线程值,例如:

I'm using annotations to configure thread values in my test case, example:

@Test(threadPoolSize = 2, invocationCount = 10)
    public void testOne() {
        //some code
    }

我们的想法是在配置文件中配置这些值,并将这些值传递给所有测试.

因此,我需要从配置条目中更改这些值,或者将该值通过unitTest构造函数传递,但TestNG仅接受CONSTANT值.

The idea is config these values in a config file and this values should be passed to all tests.

So I need to change these values from a config entry or pass this value through unitTest constructor, but TestNG is only accepting CONSTANT values.

有任何提示/想法吗?

提前谢谢!

推荐答案

您需要使用"IAnnotationTransformer"接口通过.properties文件配置"invocationCount"和"threadPoolSize"参数值,以覆盖默认值.

You need to use "IAnnotationTransformer" interface to make "invocationCount" and "threadPoolSize" parameter values configurable through a .properties file to override default values.

为解决此问题,我创建了一个示例示例.请检出 https://github.com/pashtika/test-ng/tree/master/testng-annotation-configurable .

To address this issue, I've created a Sample Example. Please check this out https://github.com/pashtika/test-ng/tree/master/testng-annotation-configurable.

这篇关于单元测试框架-TestNG使用可配置的值定义threadPoolSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆