本文整理汇总了Java中org.testng.ITestClass类的典型用法代码示例。如果您正苦于以下问题:Java ITestClass类的具体用法?Java ITestClass怎么用?Java ITestClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITestClass类属于org.testng包,在下文中一共展示了ITestClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBeforeClass
import org.testng.ITestClass; //导入依赖的package包/类
@Override
public void onBeforeClass(ITestClass testClass) {
try {
String device = testClass.getXmlClass().getAllParameters().get("device").toString();
String className = testClass.getRealClass().getSimpleName();
deviceAllocationManager.allocateDevice(device,
deviceAllocationManager.getNextAvailableDeviceId());
if (getClass().getAnnotation(Description.class) != null) {
testDescription = getClass().getAnnotation(Description.class).value();
}
reportManager.createParentNodeExtent(className,
testDescription);
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: onBeforeClass
import org.testng.ITestClass; //导入依赖的package包/类
public void onBeforeClass(final ITestClass testClass) {
final String uuid = UUID.randomUUID().toString();
final TestResultContainer container = new TestResultContainer()
.withUuid(uuid)
.withName(testClass.getName());
getLifecycle().startTestContainer(container);
classContainerUuidStorage.put(testClass, uuid);
}
示例3: onAfterClass
import org.testng.ITestClass; //导入依赖的package包/类
public void onAfterClass(final ITestClass testClass) {
if (!classContainerUuidStorage.containsKey(testClass)) {
return;
}
final String uuid = classContainerUuidStorage.get(testClass);
getLifecycle().stopTestContainer(uuid);
getLifecycle().writeTestContainer(uuid);
}
示例4: onStart
import org.testng.ITestClass; //导入依赖的package包/类
/**
* Invoked when tests from a new class are about to start
* @param testClass the class under test
*/
public void onStart( ITestClass testClass ) {
if (ActiveDbAppender.getCurrentInstance() != null) {
String suiteName = testClass.getName();
String suiteSimpleName = suiteName.substring(suiteName.lastIndexOf('.') + 1);
String packageName = getPackageName(suiteName);
logger.startSuite(packageName, suiteSimpleName);
lastSuiteName = suiteName;
}
}
示例5: onBeforeClass
import org.testng.ITestClass; //导入依赖的package包/类
/**
* [IClassListener]
* Invoked after the test class is instantiated and before
* {@link org.testng.annotations.BeforeClass @BeforeClass}
* configuration methods are called.
*
* @param testClass TestNG representation for the current test class
*/
@Override
public void onBeforeClass(ITestClass testClass) {
synchronized (classListeners) {
for (IClassListener classListener : Lists.reverse(classListeners)) {
classListener.onBeforeClass(testClass);
}
}
}
示例6: onAfterClass
import org.testng.ITestClass; //导入依赖的package包/类
/**
* [IClassListener]
* Invoked after all of the test methods of the test class have been invoked
* and before {@link org.testng.annotations.AfterClass @AfterClass}
* configuration methods are called.
*
* @param testClass TestNG representation for the current test class
*/
@Override
public void onAfterClass(ITestClass testClass) {
synchronized (classListeners) {
for (IClassListener classListener : classListeners) {
classListener.onAfterClass(testClass);
}
}
}
示例7: beforeInvocation
import org.testng.ITestClass; //导入依赖的package包/类
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
PreConfiguration preconfigure = null;
ITestClass testClass=method.getTestMethod().getTestClass();
Class<?> webClass=testClass.getRealClass();
if(testResult.getMethod().isBeforeClassConfiguration() && testResult.getMethod().getMethodName().equalsIgnoreCase("beforeClass")) {
preconfigure=webClass.getAnnotation(PreConfiguration.class);
}
//Set session as testNG attribute for after configuration methods
try{
testResult.setAttribute("session", SessionContext.session());}
catch(Exception ex) {}
if(method.getTestMethod().isTest()){
log.debug("Set assertion type parameter for test method: {}!!!", method.getTestMethod().getMethodName());
SeleniumTest seleniumTest=AnnotationUtils.findAnnotation(method.getTestMethod().getConstructorOrMethod().getMethod(), SeleniumTest.class);
ApplicationContextProvider.getApplicationContext().getBean(ApplicationContextProvider.class).publishTestNGEvent(seleniumTest, "Initialize objects for the @Test method: "+method.getTestMethod().getMethodName());
preconfigure = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(PreConfiguration.class);
}
//Execute Method from Page Object or Page Facade prior to @Test execution
if(preconfigure!=null && method.getTestMethod().getCurrentInvocationCount()==0) {
log.debug("Preconfiguration steps will be executed now for @Test {} !!!",method.getTestMethod().getMethodName());
executionConfiguration(preconfigure);
}
}
示例8: onTestStart
import org.testng.ITestClass; //导入依赖的package包/类
@Override
@SuppressWarnings({"Indentation", "PMD.ExcessiveMethodLength"})
public void onTestStart(final ITestResult testResult) {
Current current = currentTestResult.get();
if (current.isStarted()) {
current = refreshContext();
}
current.test();
final String parentUuid = getUniqueUuid(testResult.getTestContext());
final ITestNGMethod method = testResult.getMethod();
final ITestClass testClass = method.getTestClass();
final List<Label> labels = new ArrayList<>();
labels.addAll(Arrays.asList(
//Packages grouping
new Label().withName("package").withValue(testClass.getName()),
new Label().withName("testClass").withValue(testClass.getName()),
new Label().withName("testMethod").withValue(method.getMethodName()),
//xUnit grouping
new Label().withName("parentSuite").withValue(safeExtractSuiteName(testClass)),
new Label().withName("suite").withValue(safeExtractTestTag(testClass)),
new Label().withName("subSuite").withValue(safeExtractTestClassName(testClass)),
//Timeline grouping
new Label().withName("host").withValue(getHostName()),
new Label().withName("thread").withValue(getThreadName())
));
labels.addAll(getLabels(testResult));
final List<Parameter> parameters = getParameters(testResult);
final TestResult result = new TestResult()
.withUuid(current.getUuid())
.withHistoryId(getHistoryId(method, parameters))
.withName(getMethodName(method))
.withFullName(getQualifiedName(method))
.withStatusDetails(new StatusDetails()
.withFlaky(isFlaky(testResult))
.withMuted(isMuted(testResult)))
.withParameters(parameters)
.withLinks(getLinks(testResult))
.withLabels(labels);
processDescription(getClass().getClassLoader(), method.getConstructorOrMethod().getMethod(), result);
getLifecycle().scheduleTestCase(parentUuid, result);
getLifecycle().startTestCase(current.getUuid());
final String uuid = current.getUuid();
Optional.of(testResult)
.map(ITestResult::getMethod)
.map(ITestNGMethod::getTestClass)
.map(classContainerUuidStorage::get)
.ifPresent(testClassContainerUuid -> getLifecycle().updateTestContainer(
testClassContainerUuid,
container -> container.getChildren().add(uuid)
));
}
示例9: safeExtractSuiteName
import org.testng.ITestClass; //导入依赖的package包/类
private static String safeExtractSuiteName(final ITestClass testClass) {
final Optional<XmlTest> xmlTest = Optional.ofNullable(testClass.getXmlTest());
return xmlTest.map(XmlTest::getSuite).map(XmlSuite::getName).orElse("Undefined suite");
}
示例10: safeExtractTestTag
import org.testng.ITestClass; //导入依赖的package包/类
private static String safeExtractTestTag(final ITestClass testClass) {
final Optional<XmlTest> xmlTest = Optional.ofNullable(testClass.getXmlTest());
return xmlTest.map(XmlTest::getName).orElse("Undefined testng tag");
}
示例11: safeExtractTestClassName
import org.testng.ITestClass; //导入依赖的package包/类
private static String safeExtractTestClassName(final ITestClass testClass) {
return firstNonEmpty(testClass.getTestName(), testClass.getName()).orElse("Undefined class name");
}
示例12: onBeforeClass
import org.testng.ITestClass; //导入依赖的package包/类
@Override
public void onBeforeClass(ITestClass testClass) {
beforeClass.add(testClass.getRealClass().getSimpleName());
}
示例13: onAfterClass
import org.testng.ITestClass; //导入依赖的package包/类
@Override
public void onAfterClass(ITestClass testClass) {
afterClass.add(testClass.getRealClass().getSimpleName());
}
示例14: resultSummary
import org.testng.ITestClass; //导入依赖的package包/类
/**
* @param tests
*/
private void resultSummary(IResultMap tests, String testname, String style, String details)
{
if (tests.getAllResults().size() > 0)
{
StringBuffer buff = new StringBuffer();
String lastClassName = "";
int mq = 0;
int cq = 0;
for (ITestNGMethod method : getMethodSet(tests))
{
m_row += 1;
m_methodIndex += 1;
ITestClass testClass = method.getTestClass();
String className = testClass.getName();
if (mq == 0)
{
titleRow(testname + " — " + style + details, 4);
}
if (!className.equalsIgnoreCase(lastClassName))
{
if (mq > 0)
{
cq += 1;
m_out.println("<tr class=\"" + style
+ (cq % 2 == 0 ? "even" : "odd") + "\">" + "<td rowspan=\""
+ mq + "\">" + lastClassName + buff);
}
mq = 0;
buff.setLength(0);
lastClassName = className;
}
Set<ITestResult> resultSet = tests.getResults(method);
long end = Long.MIN_VALUE;
long start = Long.MAX_VALUE;
for (ITestResult testResult : tests.getResults(method))
{
if (testResult.getEndMillis() > end)
{
end = testResult.getEndMillis();
}
if (testResult.getStartMillis() < start)
{
start = testResult.getStartMillis();
}
}
mq += 1;
if (mq > 1)
{
buff.append("<tr class=\"" + style + (cq % 2 == 0 ? "odd" : "even")
+ "\">");
}
String description = method.getDescription();
String testInstanceName = resultSet.toArray(new ITestResult[]{})[0].getTestName();
buff.append("<td><a href=\"#m" + m_methodIndex + "\">"
+ qualifiedName(method)
+ " " + (description != null && description.length() > 0
? "(\"" + description + "\")"
: "")
+ "</a>" + (null == testInstanceName ? "" : "<br>(" + testInstanceName + ")")
+ "</td>" + "<td class=\"numi\">"
+ resultSet.size() + "</td><td class=\"numi\">" + (end - start)
+ "</td></tr>");
}
if (mq > 0)
{
cq += 1;
m_out.println("<tr class=\"" + style + (cq % 2 == 0 ? "even" : "odd")
+ "\">" + "<td rowspan=\"" + mq + "\">" + lastClassName + buff);
}
}
}
示例15: onAfterClass
import org.testng.ITestClass; //导入依赖的package包/类
@Override
public void onAfterClass(ITestClass iTestClass, IMethodInstance iMethodInstance) {
MockInitialContextFactory.destroy();
}