Unit test framework - TestNG using configurable value to define threadPoolSize

岁酱吖の 提交于 2020-01-02 23:45:50

问题


I'm digging little bit the TestNG framework.

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

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

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.

Any tips/ideas?

Thanks in advance!


回答1:


Use an annotation transformer:

http://testng.org/javadocs/org/testng/IAnnotationTransformer.html




回答2:


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

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.



来源:https://stackoverflow.com/questions/2418907/unit-test-framework-testng-using-configurable-value-to-define-threadpoolsize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!