问题
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