Java Code Examples for org.testng.ITestContext#getName()
The following examples show how to use
org.testng.ITestContext#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseTest.java From at.info-knowledge-base with MIT License | 6 votes |
private void configureProxy(final ITestContext context, final Method method) { final MonitorNetwork monitorNetwork = method.getAnnotation(MonitorNetwork.class); if (monitorNetwork != null && monitorNetwork.enabled()) { final String initialPageID = context.getName() + " : " + method.getName(); harDetailsLink = HAR_STORAGE.getHarDetailsURL(initialPageID); proxy = new BrowserMobProxy(PROXY_IP, PROXY_PORT); proxy.setSocketOperationTimeout(DEFAULT_SOCKET_TIMEOUT); proxy.setRequestTimeout(DEFAULT_REQUEST_TIMEOUT); // Getting port for Selenium proxy final int port = proxy.getPort(); proxy.setPort(port); // Creating har on raised proxy for monitoring net statistics before first page is loaded. proxy.newHar(initialPageID, monitorNetwork.captureHeaders(), monitorNetwork.captureContent(), monitorNetwork.captureBinaryContent()); // Get the Selenium proxy object final String actualProxy = PROXY_IP + ":" + port; seleniumProxy = new Proxy(); seleniumProxy.setHttpProxy(actualProxy).setFtpProxy(actualProxy) .setSslProxy(actualProxy); } }
Example 2
Source File: TestResults.java From at.info-knowledge-base with MIT License | 6 votes |
public TestResults(final ITestContext context) { this.name = context.getName(); this.passed = context.getPassedTests().size(); this.failed = context.getFailedTests().size(); this.skipped = context.getSkippedTests().size(); this.startDate = context.getStartDate(); this.endDate = context.getEndDate(); final int totalTests = passed + failed + skipped; final int incompleteTests = failed + skipped; this.passRate = PASS_RATE_FORMAT.format((double) (totalTests - incompleteTests) * 100 / totalTests); this.duration = DURATION_FORMAT.format((double) (endDate.getTime() - startDate.getTime()) / 1000); this.highlightPassed = passed > 0 ? Highlight.PASSED.name().toLowerCase() : Highlight.ZERO.name().toLowerCase(); this.highlightFailed = failed > 0 ? Highlight.FAILED.name().toLowerCase() : Highlight.ZERO.name().toLowerCase(); this.highlightSkipped = skipped > 0 ? Highlight.SKIPPED.name().toLowerCase() : Highlight.ZERO.name().toLowerCase(); }
Example 3
Source File: TestNGTestResultProcessorAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void onStart(ITestContext iTestContext) { TestDescriptorInternal testInternal; synchronized (lock) { testInternal = new DefaultTestSuiteDescriptor(idGenerator.generateId(), iTestContext.getName()); suites.put(testInternal.getName(), testInternal.getId()); for (ITestNGMethod method : iTestContext.getAllTestMethods()) { testMethodToSuiteMapping.put(method, testInternal.getId()); } } resultProcessor.started(testInternal, new TestStartEvent(iTestContext.getStartDate().getTime())); }
Example 4
Source File: TestNGTestResultProcessorAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void onStart(ITestContext iTestContext) { TestDescriptorInternal testInternal; synchronized (lock) { testInternal = new DefaultTestSuiteDescriptor(idGenerator.generateId(), iTestContext.getName()); suites.put(testInternal.getName(), testInternal.getId()); for (ITestNGMethod method : iTestContext.getAllTestMethods()) { testMethodToSuiteMapping.put(method, testInternal.getId()); } } resultProcessor.started(testInternal, new TestStartEvent(iTestContext.getStartDate().getTime())); }
Example 5
Source File: PowerEmailableReporter.java From WebAndAppUITesting with GNU General Public License v3.0 | 5 votes |
/** * Creates a table showing the highlights of each test method with links to * the method details */ protected void generateMethodSummaryReport(List<ISuite> suites) { startResultSummaryTable("methodOverview"); int testIndex = 1; for (ISuite suite : suites) { if (suites.size() > 1) { titleRow(suite.getName(), 5); } Map<String, ISuiteResult> r = suite.getResults(); for (ISuiteResult r2 : r.values()) { ITestContext testContext = r2.getTestContext(); String testName = testContext.getName(); m_testIndex = testIndex; // resultSummary(suite, testContext.getSkippedConfigurations(), // testName, "skipped", // " (configuration methods)"); resultSummary(suite, testContext.getSkippedTests(), testName, "skipped", ""); // resultSummary(suite, testContext.getFailedConfigurations(), // testName, "failed", // " (configuration methods)"); resultSummary(suite, testContext.getFailedTests(), testName, "failed", ""); resultSummary(suite, testContext.getPassedTests(), testName, "passed", ""); testIndex++; } } m_out.println("</table>"); }
Example 6
Source File: CustomTestNgListener.java From heat with Apache License 2.0 | 5 votes |
/** * This method is useful to print the output console log in case of test failed. * We are assuming that we put in the context an attribute whose name is the complete test case ID (example: TEST_SUITE.001) and whose value is * 'PASSED' or 'SKIPPED' or 'FAILED'. * @param tr test case result - testNG handling */ @Override public void onTestFailure(ITestResult tr) { if (tr.getParameters().length > 0) { Map<String, String> paramMap = (HashMap<String, String>) tr.getParameters()[0]; ITestContext testContext = tr.getTestContext(); //testCaseCompleteID - Example: TEST_SUITE.001 String testCaseCompleteID = testContext.getName() + TestBaseRunner.TESTCASE_ID_SEPARATOR + testContext.getAttribute(TestBaseRunner.ATTR_TESTCASE_ID); logger.error("[{}][{}][{}] -- FAILED", testCaseCompleteID, testContext.getAttribute(TestBaseRunner.SUITE_DESCRIPTION_CTX_ATTR).toString(), testContext.getAttribute(TestBaseRunner.TC_DESCRIPTION_CTX_ATTR).toString()); if (testContext.getAttribute(FAILED_TEST_CASES) == null) { failedTc = new ArrayList(); } else { failedTc = (List<ITestResult>) testContext.getAttribute(FAILED_TEST_CASES); } failedTc.add(tr); testContext.setAttribute(FAILED_TEST_CASES, failedTc); } else { super.onTestFailure(tr); } }
Example 7
Source File: CustomTestNgListener.java From heat with Apache License 2.0 | 5 votes |
/** * This method is useful to print the output console log in case of test success or test skipped. * We are assuming that we put in the context an attribute whose name is the complete test case ID (example: TEST_SUITE.001) and whose value is * 'PASSED' or 'SKIPPED' or 'FAILED'. * @param tr test case result - testNG handling */ @Override public void onTestSuccess(ITestResult tr) { if (tr.getParameters().length > 0) { Map<String, String> paramMap = (HashMap<String, String>) tr.getParameters()[0]; ITestContext testContext = tr.getTestContext(); //testCaseCompleteID - Example: TEST_SUITE.001 String testCaseCompleteID = testContext.getName() + TestBaseRunner.TESTCASE_ID_SEPARATOR + testContext.getAttribute(TestBaseRunner.ATTR_TESTCASE_ID); if (testContext.getAttributeNames().contains(testCaseCompleteID) && TestBaseRunner.STATUS_SKIPPED.equals(testContext.getAttribute(testCaseCompleteID))) { logger.info("[{}][{}][{}] -- SKIPPED", testCaseCompleteID, testContext.getAttribute(TestBaseRunner.SUITE_DESCRIPTION_CTX_ATTR).toString(), testContext.getAttribute(TestBaseRunner.TC_DESCRIPTION_CTX_ATTR).toString()); if (testContext.getAttribute(SKIPPED_TEST_CASES) == null) { skippedTc = new ArrayList(); } else { skippedTc = (List<ITestResult>) testContext.getAttribute(SKIPPED_TEST_CASES); } skippedTc.add(tr); testContext.setAttribute(SKIPPED_TEST_CASES, skippedTc); } else { logger.info("[{}][{}][{}] -- PASSED", testCaseCompleteID, testContext.getAttribute(TestBaseRunner.SUITE_DESCRIPTION_CTX_ATTR).toString(), testContext.getAttribute(TestBaseRunner.TC_DESCRIPTION_CTX_ATTR).toString()); if (testContext.getAttribute(PASSED_TEST_CASES) == null) { passedTc = new ArrayList(); } else { passedTc = (List<ITestResult>) testContext.getAttribute(PASSED_TEST_CASES); } passedTc.add(tr); testContext.setAttribute(PASSED_TEST_CASES, passedTc); } } else { super.onTestSuccess(tr); } }
Example 8
Source File: TestNGTestResultProcessorAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void onStart(ITestContext iTestContext) { TestDescriptorInternal testInternal; synchronized (lock) { testInternal = new DefaultTestSuiteDescriptor(idGenerator.generateId(), iTestContext.getName()); suites.put(testInternal.getName(), testInternal.getId()); for (ITestNGMethod method : iTestContext.getAllTestMethods()) { testMethodToSuiteMapping.put(method, testInternal.getId()); } } resultProcessor.started(testInternal, new TestStartEvent(iTestContext.getStartDate().getTime())); }
Example 9
Source File: TestNGTestResultProcessorAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void onStart(ITestContext iTestContext) { TestDescriptorInternal testInternal; synchronized (lock) { testInternal = new DefaultTestSuiteDescriptor(idGenerator.generateId(), iTestContext.getName()); suites.put(testInternal.getName(), testInternal.getId()); for (ITestNGMethod method : iTestContext.getAllTestMethods()) { testMethodToSuiteMapping.put(method, testInternal.getId()); } } resultProcessor.started(testInternal, new TestStartEvent(iTestContext.getStartDate().getTime())); }
Example 10
Source File: TestStatusListener.java From concurrentlinkedhashmap with Apache License 2.0 | 5 votes |
@Override public void onStart(ITestContext context) { if (executionStart) { System.out.println(); executionStart = false; } testSuite = context.getName(); showSuite = true; }
Example 11
Source File: AbstractDifidoReporter.java From difido-reports with Apache License 2.0 | 5 votes |
@Override public void onStart(ITestContext context) { ScenarioNode scenario = new ScenarioNode(context.getName()); currentMachine.addChild(scenario); currentTestScenario = scenario; // TODO: We want to avoid a case in which there is the same test class // in different tests and a new scenario class is not created testClassName = null; }
Example 12
Source File: VerboseReporter.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override public void onStart(ITestContext ctx) { suiteName = ctx.getName();//ctx.getSuite().getXmlSuite().getFileName(); log("RUNNING: Suite: \"" + suiteName + "\" containing \"" + ctx.getAllTestMethods().length + "\" Tests (config: " + ctx.getSuite().getXmlSuite().getFileName() + ")"); }