开发者

When using the IObjectFactory in TestNG, do all my test classes need to be created up front?

I'm running some Selenium 2 tests through TestNG and I'm trying to use Guice modules to automatically inject a configured browser (driver) into my tests. I'm using the IObjectFactory method described in the TestNG book, an开发者_运维百科d implemented by testnguice, but i've run into an issue.

It seems that all my test classes are being created, and the browser instance initialized, as soon as the tests suite starts. This wouldn't be such a problem if my classes only had lightweight objects, but in my case this means I've got a half dozen browsers being fired up and sitting around until their test is run.

Is it possible to tell TestNG to create the test class right before the test is run?

for reference here's the testng.xml used to start the tests. I'm running everything inside eclipse.

<suite name="Suite1" verbose="1"  object-factory="com.corp.Testing.ObjectFactory.LocalFirefox">

LocalFirefox is equally unremarkable

package com.corp.Testing.ObjectFactory;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class LocalFirefox extends GuiceObjectFactory {

 @Override
 protected void configure() {
  bind(WebDriver.class).to(FirefoxDriver.class);
 }

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜