本文整理汇总了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();
}