我可以使用从文件中读取的testng组吗?

时间:2017-07-17 07:49:10

标签: java testng

我尝试使用从外部文件读取的testng组。它给出了一个编译时错误,指出它只能接受字符串常量。它看起来如下:

@Autowired
public RestTokenUserOnboardRoute userOnboardRoute;
@Autowired
public RestTokenProducerRoute serviceTokenProducerRoute;

@Autowired
private RestTokenProducerRoute tokenObj;

@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry(); 
    registry.put("tokenObj", tokenObj); //the tokenObj bean,which can be used anywhere in the camelcontext
    SpringCamelContext camelContext = new SpringCamelContext();
    camelContext.setRegistry(registry); //add the registry
    camelContext.setApplicationContext(getApplicationContext());
    camelContext.addComponent("salesforce", salesforceComponent());
    camelContext.getTypeConverterRegistry().addTypeConverter(DomainUserRequest.class, MyUser__c.class, new MyTypeConverter());
    camelContext.addRoutes(route()); //Some other route
    camelContext.addRoutes(serviceTokenProducerRoute); //Token producer Route
    camelContext.addRoutes(userOnboardRoute); //Subsequent API call route
    camelContext.start();
    return camelContext;
}

到目前为止我无法使用TestNG执行上述操作。这样做有没有办法呢?

1 个答案:

答案 0 :(得分:1)

也许您可以尝试围绕TestNG作为监听器提供的org.testng.IAnnotationTransformer接口构建实现,并且在其org.testng.IAnnotationTransformer#transform方法中,您可以动态地注入组信息。您的transform()实现可以丰富,以便从外部数据源读取组信息。这应该可以解决你的问题。