With some help from TestNG contributors, I've managed to get a default Guice ParentModule setup by using the ServiceLoader and IAltersuiteListener. Now I have another barrier I'd like to overcome.
From this ParentModule point, I've been able to bind the suite configuration and browser capabilities. One of the bindings is an Iterable<DesiredCapabilities> that I would then like to break down into one-per-suite. I'd prefer to avoid annotations and test class inheritance if possible, and opt for something behind the scenes, as I think a complex test class rig here will make it more difficult to train new testers.
I've done this in the past with a JUnit runner, where the final modules are composed at the time the test method object is created, which is where the injection takes place as well.
To break it down, this is the flow I'm looking for:
1. When TestNG starts, auto-load the configuration and browser capabilities. Say one for firefox, one chrome. (done)
2. For each of the capabilities in the iterable, duplicate the tests/suite.
3. Pass a capability instance (firefox) to a test, then create a webdriver guice module and inject the test instance with the capability+module..
4. Run the test class (or method?)
5. Repeat 3 and 4 for Chrome.
Through some experimentation, I've managed to copy the suite per browser instance (for number 2 above), but I don't know if there's a way I could pass the specific browser capability into the test or testxml at the IAlterSuiteLIstener level. Also, if I try using an ITestListener to perform the later binding, I get an error on the @Inject fields in my test, as I believe TestNG is trying to resolve those bindings much earlier on in the process.
Has anybody else out there done something similar? I'd love to hear how others have done this, even if they haven't used Guice. I think the key here may be finding the right interface to perform the final injection, but it's been difficult experimenting on my own.
Thanks for taking the time to read this. I'm excited to see where our suites can go from here.