有没有办法将ITestContext从TestNg注入guice模块?

有没有办法将ITestContext从TestNg注入guice模块?,testng,guice,Testng,Guice,假设我有一些guice模块/提供程序,它应该根据从TestNg套件文件接收的参数创建绑定。e、 g <test name="Test"> <parameter name="profile" value="chrome"></parameter> <classes> <class name="com.apc.ui.tests.TestClass"> </class> &l

假设我有一些guice模块/提供程序,它应该根据从TestNg套件文件接收的参数创建绑定。e、 g

<test name="Test">
    <parameter name="profile" value="chrome"></parameter>
    <classes>
        <class name="com.apc.ui.tests.TestClass">
        </class>
    </classes>
</test>

所以,我想知道这是否可能。任何替代方案都是受欢迎的。谢谢。

最终,我在testNg源代码中找到了解决方案。可以在套件文件中设置所谓的父模块

<suite name="Suite1" verbose="1" parallel="false"
    parent-module="org.my.tests.ParentModule">
...

但是它不会为其他所有测试注入相同的上下文吗?它会,但是上下文可以访问套件中的所有测试。因此,实际上可以访问xml套件中当前正在运行的测试项。我尝试了这个方法-通过注入适当的测试上下文,效果非常好-@KitKarson您能在这里给出一个基本示例吗?假设我想通过上下文传递一些参数值,我们用这种方法实现了吗?
<suite name="Suite1" verbose="1" parallel="false"
    parent-module="org.my.tests.ParentModule">
...
public class ParentModule extends AbstractModule {

  private ITestContext context;

  public GuiceParentModule(ITestContext context) {
    this.context = context;
  }

  @Override
  protected void configure() {
    bind(ITestContext.class).toInstance(context);
  }
...