本文整理匯總了Java中org.junit.rules.TestWatcher類的典型用法代碼示例。如果您正苦於以下問題:Java TestWatcher類的具體用法?Java TestWatcher怎麽用?Java TestWatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TestWatcher類屬於org.junit.rules包,在下文中一共展示了TestWatcher類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSauceLabsTestWatcher
import org.junit.rules.TestWatcher; //導入依賴的package包/類
public TestWatcher getSauceLabsTestWatcher() {
if (!SauceLabs.useSauceLabs()) {
return new TestWatcher() {};
}
String sauceUsername = System.getenv("SAUCE_USERNAME");
String sauceAccessKey = System.getenv("SAUCE_ACCESS_KEY");
SauceOnDemandAuthentication authentication =
new SauceOnDemandAuthentication(sauceUsername, sauceAccessKey);
SauceOnDemandSessionIdProvider sessionIdProvider = new SauceOnDemandSessionIdProvider() {
@Override
public String getSessionId() {
return remoteWebDriverSessionId;
}
};
return new SauceOnDemandTestWatcher(sessionIdProvider, authentication);
}
示例2: getTestWatcher
import org.junit.rules.TestWatcher; //導入依賴的package包/類
/**
* Get test watcher to manage driver instances.
*
* @param obj test class instance extending {@link TestBase}
* @return test watcher object
*/
public static TestWatcher getTestWatcher(final TestBase obj) {
return new TestWatcher() {
@Override
protected void finished(Description description) {
DriverManager.closeDriver(obj);
}
};
}
示例3: testWatcherCreator
import org.junit.rules.TestWatcher; //導入依賴的package包/類
/**
* This function create a TestWatcher writing on screen the names of called
* classes and methods.
*
* @return the TestWatcher created
*/
public static TestWatcher testWatcherCreator() {
return new TestWatcher() {
protected void starting(Description description) {
System.out.println("\nStarting example : " + description.getMethodName() + " from : "
+ description.getClassName() + " class.");
}
};
}
示例4: newWatcher
import org.junit.rules.TestWatcher; //導入依賴的package包/類
public static TestWatcher newWatcher(final Class clazz, final long seed)
{
return new TestWatcher()
{
protected void failed(final Throwable t, final Description description)
{
System.err.println(clazz.getName() + " failed with random seed: " + seed);
}
};
}
示例5: applyTo
import org.junit.rules.TestWatcher; //導入依賴的package包/類
@Override
public TestRule applyTo(final JenkinsInstance instance) {
return new TestWatcher() {
@Override
protected void starting(Description description) {
int portNumber = anyFreeLocalPortInRange(rangeStart, rangeEnd);
Log.info("Found a free port: {}", portNumber);
instance.setPort(portNumber);
}
};
}
示例6: applyTo
import org.junit.rules.TestWatcher; //導入依賴的package包/類
@Override
public TestRule applyTo(final JenkinsInstance jenkins) {
return new TestWatcher() {
@Override
protected void starting(Description test) {
Path jenkinsHome = temporaryJenkinsHomeFor(test);
Log.info("Setting jenkins home to {}", jenkinsHome);
jenkins.setHome(jenkinsHome);
}
};
}
示例7: applyTo
import org.junit.rules.TestWatcher; //導入依賴的package包/類
@Override
public TestRule applyTo(final JenkinsInstance jenkins) {
return new TestWatcher() {
@Override
protected void starting(Description description) {
jenkins.client().registerAccount(user.getName(), user.password());
}
};
}
示例8: applyTo
import org.junit.rules.TestWatcher; //導入依賴的package包/類
@Override
public TestRule applyTo(final JenkinsInstance jenkins) {
return new TestWatcher() {
@Override protected void starting(Description description) {
warmUpUpdateCenterCacheFor(jenkins);
jenkins.client().installPlugins(requiredPlugins);
}
};
}
示例9: hasZeroFields
import org.junit.rules.TestWatcher; //導入依賴的package包/類
@Test
public void hasZeroFields() throws Exception {
Field[] fields = TestWatcher.class.getDeclaredFields();
assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).isEqualTo(0);
}
示例10: getSauceLabsTestWatcher
import org.junit.rules.TestWatcher; //導入依賴的package包/類
@Rule
public TestWatcher getSauceLabsTestWatcher() {
return setup.getSauceLabsTestWatcher();
}
示例11: innerRule
import org.junit.rules.TestWatcher; //導入依賴的package包/類
@Override
protected TestWatcher innerRule() {
return innerRule;
}
示例12: createWatcher
import org.junit.rules.TestWatcher; //導入依賴的package包/類
/**
* Create watcher for JUnit
* @return a watcher for use with JUnit
*/
public static TestWatcher createWatcher() {
return provider.createWatcher();
}