本文整理汇总了Java中org.testng.ITestContext类的典型用法代码示例。如果您正苦于以下问题:Java ITestContext类的具体用法?Java ITestContext怎么用?Java ITestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITestContext类属于org.testng包,在下文中一共展示了ITestContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculate
import org.testng.ITestContext; //导入依赖的package包/类
private void calculate() {
if (!this.counts.isEmpty()) return;
int passed = 0;
int failed = 0;
int skipped = 0;
for (ISuite suite : this.reports) {
for (ISuiteResult result : suite.getResults().values()) {
final ITestContext testContext = result.getTestContext();
passed += testContext.getPassedTests().size();
failed += testContext.getFailedTests().size();
skipped += testContext.getSkippedTests().size();
}
}
this.counts.add(0, passed + failed + skipped);
this.counts.add(1, failed);
this.counts.add(2, skipped);
}
示例2: generateMethodDetailReport
import org.testng.ITestContext; //导入依赖的package包/类
/**
* Creates a section showing known results for each method
*/
protected void generateMethodDetailReport(List<ISuite> suites)
{
m_methodIndex = 0;
for (ISuite suite : suites)
{
Map<String, ISuiteResult> r = suite.getResults();
for (ISuiteResult r2 : r.values())
{
ITestContext testContext = r2.getTestContext();
if (r.values().size() > 0)
{
m_out.println("<h1>" + testContext.getName() + "</h1>");
}
resultDetail(testContext.getFailedConfigurations(), "failed");
resultDetail(testContext.getFailedTests(), "failed");
resultDetail(testContext.getSkippedConfigurations(), "skipped");
resultDetail(testContext.getSkippedTests(), "skipped");
resultDetail(testContext.getPassedTests(), "passed");
}
}
}
示例3: TestClassContext
import org.testng.ITestContext; //导入依赖的package包/类
protected TestClassContext(Class testClass, AbstractTest testInstance, Class<? extends Annotation> annotationClassToInvokeMethods, ITestContext testContext) {
this.testClass = testClass;
this.testInstance = testInstance;
this.annotationClassToInvokeMethods = annotationClassToInvokeMethods;
if (testContext.getExcludedGroups() == null) {
this.excludedGroups = new String[0];
} else {
this.excludedGroups = Arrays.copyOf(testContext.getExcludedGroups(), testContext.getExcludedGroups().length);
}
if (testContext.getIncludedGroups() == null) {
this.includedGroups = new String[0];
} else {
this.includedGroups = Arrays.copyOf(testContext.getIncludedGroups(), testContext.getIncludedGroups().length);
}
this.testContext = testContext;
}
示例4: afterInvocation
import org.testng.ITestContext; //导入依赖的package包/类
@Override
public void afterInvocation(final IInvokedMethod method, final ITestResult testResult,
final ITestContext context) {
final ITestNGMethod testMethod = method.getTestMethod();
if (isSupportedConfigurationFixture(testMethod)) {
final String executableUuid = currentExecutable.get();
currentExecutable.remove();
if (testResult.isSuccess()) {
getLifecycle().updateFixture(executableUuid, result -> result.withStatus(Status.PASSED));
} else {
getLifecycle().updateFixture(executableUuid, result -> result
.withStatus(getStatus(testResult.getThrowable()))
.withStatusDetails(getStatusDetails(testResult.getThrowable()).orElse(null)));
}
getLifecycle().stopFixture(executableUuid);
if (testMethod.isBeforeMethodConfiguration() || testMethod.isAfterMethodConfiguration()) {
final String containerUuid = currentTestContainer.get();
validateContainerExists(getQualifiedName(testMethod), containerUuid);
currentTestContainer.remove();
getLifecycle().stopTestContainer(containerUuid);
getLifecycle().writeTestContainer(containerUuid);
}
}
}
示例5: onTestSkipped
import org.testng.ITestContext; //导入依赖的package包/类
/**
* [ITestListener]
* Invoked each time a test is skipped.
*
* @param result {@code ITestResult} containing information about the run test
* @see ITestResult#SKIP
*/
@Override
public void onTestSkipped(ITestResult result) {
// >>>>> ENTER workaround for TestNG bug
// https://github.com/cbeust/testng/issues/1602
ITestContext context = result.getTestContext();
IInvokedMethod method = new InvokedMethod(
result.getTestClass(), result.getMethod(), System.currentTimeMillis(), result);
beforeInvocation(method, result, context);
// <<<<< LEAVE workaround for TestNG bug
synchronized (testListeners) {
for (ITestListener testListener : testListeners) {
testListener.onTestSkipped(result);
}
}
}
示例6: createModule
import org.testng.ITestContext; //导入依赖的package包/类
@Override
public Module createModule(ITestContext context, Class<?> testClass){
Module globalModule = new AbstractModule(){
@Override
protected void configure(){
for(Module module : modules){
install(module);
}
}
};
Iterable<? extends Module> overriders = getOverriders();
return Modules.override(globalModule).with(overriders);
}
示例7: cleanupAfterSuite
import org.testng.ITestContext; //导入依赖的package包/类
@AfterSuite
public void cleanupAfterSuite(ITestContext context)
{
if( suite != null )
{
@SuppressWarnings("unchecked")
List<CleanupAfter> cleanups = (List<CleanupAfter>) suite.getAttribute("cleanups");
if( cleanups != null )
{
ListIterator<CleanupAfter> listIterator = cleanups.listIterator(cleanups.size());
while( listIterator.hasPrevious() )
{
CleanupAfter cleanup = listIterator.previous();
if( cleanup != null )
{
cleanup.cleanUp();
}
}
}
}
}
示例8: setupContext
import org.testng.ITestContext; //导入依赖的package包/类
@BeforeClass(alwaysRun = true)
public void setupContext(ITestContext testContext)
{
this.suite = testContext.getSuite();
File rootFolder = testConfig.getTestFolder();
String contextUrl;
if( isInstitutional() )
{
contextUrl = testConfig.getInstitutionUrlFromShortName(rootFolder.getName());
}
else
{
contextUrl = testConfig.getAdminUrl();
}
context = new PageContext(testConfig, contextUrl);
context.setIntegUrl(testConfig.getIntegrationUrl(rootFolder.getName()));
context.setNamePrefix(getNamePrefix());
customisePageContext();
}
示例9: getAllParametersForTest
import org.testng.ITestContext; //导入依赖的package包/类
public Map<String, String> getAllParametersForTest(String testName)
{
ITestContext overview = null;
for (ISuite suite : suites)
{
Map<String, ISuiteResult> tests = suite.getResults();
for (ISuiteResult r : tests.values())
{
overview = r.getTestContext();
if (testName.equalsIgnoreCase(overview.getName()))
{
return overview.getCurrentXmlTest().getAllParameters();
}
}
}
return null;
}
示例10: getAllMethodsForTest
import org.testng.ITestContext; //导入依赖的package包/类
public ITestNGMethod[] getAllMethodsForTest(String testName)
{
ITestContext overview = null;
for (ISuite suite : suites)
{
suiteName = suite.getName();
Map<String, ISuiteResult> tests = suite.getResults();
for (ISuiteResult r : tests.values())
{
overview = r.getTestContext();
if (overview.getName().equalsIgnoreCase(testName))
{
return overview.getAllTestMethods();
}
}
}
return null;
}
示例11: intercept
import org.testng.ITestContext; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
示例12: onFinish
import org.testng.ITestContext; //导入依赖的package包/类
public void onFinish(ITestContext context)
{
System.err.println("TEST finished : " + context.getName());
testsCompleted.add(context.getName());
testsInProgress.remove(context.getName());
totalActualTimeTaken = context.getEndDate().getTime() - context.getStartDate().getTime();
long timeSaved = timeTakenByTestMethods - totalActualTimeTaken;
customMessage.replace(0, customMessage.length(), "");
if (timeTakenByTestMethods < 1)
{
timeTakenByTestMethods = 1;
}
customMessage.append("<span> " + "Sum of time taken for each test method : " + timeTakenByTestMethods / 1000 + " seconds!" + "</span><br/>" +
"<span> " + "Actual total time taken for run : " + totalActualTimeTaken / 1000 + " seconds!" + "</span><br/>" +
"<span>" + "Time saved : " + timeSaved / 1000 + " seconds OR " + timeSaved * 100 / timeTakenByTestMethods + "%</span>");
update();
lastUpdate = false;
}
示例13: intercept
import org.testng.ITestContext; //导入依赖的package包/类
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
ISuite suite = context.getSuite();
List<IMethodInstance> filtered = new LinkedList<IMethodInstance>();
for (IMethodInstance candidate : methods) {
if (matcher.matchesTest(candidate.getMethod().getTestClass().getName(), candidate.getMethod().getMethodName())
|| matcher.matchesTest(suite.getName(), null)) {
filtered.add(candidate);
}
}
return filtered;
}
示例14: beforeSuite
import org.testng.ITestContext; //导入依赖的package包/类
@BeforeSuite(alwaysRun = true)
public void beforeSuite(final ITestContext context) {
if (methodsInvoker == null) {
new SeleniumMethodsInvoker().invokeSuiteMethodsByAnnotation(OurBeforeSuite.class, context);
} else {
methodsInvoker.invokeSuiteMethodsByAnnotation(OurBeforeSuite.class, context);
}
}
示例15: beforeMethod
import org.testng.ITestContext; //导入依赖的package包/类
@BeforeMethod(alwaysRun = true)
public void beforeMethod(final Method test, final Object[] params, final ITestContext context) {
testName = TestUtils.getTestName(test);
postponeFailureEvent.subscribe(new ScreenshotOnPostponeFailureSubscriber(testName));
postponeFailureEvent.subscribe(new StorePostponeFailureSubscriber(context, testName));
passCounter = 0;
}