org.testng.TestListenerAdapter Java Examples
The following examples show how to use
org.testng.TestListenerAdapter.
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: SecureEmbeddedServerTestBase.java From atlas with Apache License 2.0 | 7 votes |
/** * Runs the existing webapp test cases, this time against the initiated secure server instance. * @throws Exception */ @Test public void runOtherSuitesAgainstSecureServer() throws Exception { final PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty(CERT_STORES_CREDENTIAL_PROVIDER_PATH, providerUrl); // setup the credential provider setupCredentials(); try { secureEmbeddedServer = new SecureEmbeddedServer( EmbeddedServer.ATLAS_DEFAULT_BIND_ADDRESS, securePort, TestUtils.getWarPath()) { @Override protected PropertiesConfiguration getConfiguration() { return configuration; } }; secureEmbeddedServer.server.start(); TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[]{AdminJerseyResourceIT.class, EntityJerseyResourceIT.class, TypesJerseyResourceIT.class}); testng.addListener(tla); testng.run(); } finally { secureEmbeddedServer.server.stop(); } }
Example #2
Source File: SecureEmbeddedServerTestBase.java From incubator-atlas with Apache License 2.0 | 6 votes |
/** * Runs the existing webapp test cases, this time against the initiated secure server instance. * @throws Exception */ @Test public void runOtherSuitesAgainstSecureServer() throws Exception { final PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty(CERT_STORES_CREDENTIAL_PROVIDER_PATH, providerUrl); // setup the credential provider setupCredentials(); try { secureEmbeddedServer = new SecureEmbeddedServer(securePort, TestUtils.getWarPath()) { @Override protected PropertiesConfiguration getConfiguration() { return configuration; } }; secureEmbeddedServer.server.start(); TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[]{AdminJerseyResourceIT.class, EntityJerseyResourceIT.class, MetadataDiscoveryJerseyResourceIT.class, TypesJerseyResourceIT.class}); testng.addListener(tla); testng.run(); } finally { secureEmbeddedServer.server.stop(); } }
Example #3
Source File: TestNGTests.java From quickperf with Apache License 2.0 | 5 votes |
public static TestNGTests createInstance(Class<?> testClass) { TestNG testNG = new TestNG(); testNG.setUseDefaultListeners(false); testNG.setVerbose(0); Class[] testClasses = {testClass}; testNG.setTestClasses(testClasses); TestListenerAdapter testListenerAdapter = new TestListenerAdapter(); testNG.addListener(testListenerAdapter); return new TestNGTests(testNG, testListenerAdapter); }
Example #4
Source File: CatalogYamlTemplateTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
public static void main(String[] args) { ITestNGListener tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[] { CatalogYamlTemplateTest.class }); testng.addListener(tla); testng.run(); }
Example #5
Source File: TestngRun.java From Leo with Apache License 2.0 | 5 votes |
public TestngRun() { tng=new TestNG(); listener=new TestListenerAdapter();//定义监听器类型 tng.addListener(listener); xmlFileList=new ArrayList<>();//记录测试使用的xml文件路径列表 testReport=new TestReport();//记录测试报告测试报告信息 runInfo=new TestRunInfo(); }
Example #6
Source File: TestNGTests.java From quickperf with Apache License 2.0 | 4 votes |
private TestNGTests(TestNG testNG, TestListenerAdapter testListenerAdapter) { this.testNG = testNG; this.testListenerAdapter = testListenerAdapter; }
Example #7
Source File: TestNGTests.java From quickperf with Apache License 2.0 | 4 votes |
private TestNGTestsResult(TestListenerAdapter testListenerAdapter) { this.testListenerAdapter = testListenerAdapter; }
Example #8
Source File: HybridClusterIntegrationTestCommandLineRunner.java From incubator-pinot with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { int numArgs = args.length; if (!((numArgs == 6) || (numArgs == 7 && args[0].equals("--llc")))) { printUsage(); } CustomHybridClusterIntegrationTest._enabled = true; int argIdx = 0; if (args[0].equals("--llc")) { CustomHybridClusterIntegrationTest._useLlc = true; argIdx++; } CustomHybridClusterIntegrationTest._tableName = args[argIdx++]; File schemaFile = new File(args[argIdx++]); CustomHybridClusterIntegrationTest._schema = Schema.fromFile(schemaFile); String timeColumnName = args[argIdx++]; CustomHybridClusterIntegrationTest._timeColumnName = (CustomHybridClusterIntegrationTest._schema.getFieldSpecFor(timeColumnName) != null) ? timeColumnName : null; File dataDir = new File(args[argIdx++]); Preconditions.checkState(dataDir.isDirectory()); CustomHybridClusterIntegrationTest._dataDir = dataDir; CustomHybridClusterIntegrationTest._invertedIndexColumns = Arrays.asList(args[argIdx++].split(",")); CustomHybridClusterIntegrationTest._sortedColumn = args[argIdx]; TestListenerAdapter testListenerAdapter = new TestListenerAdapter(); TestNG testNG = new TestNG(); testNG.setTestClasses(new Class[]{CustomHybridClusterIntegrationTest.class}); testNG.addListener(testListenerAdapter); testNG.run(); System.out.println(testListenerAdapter.toString()); boolean success = true; List<ITestResult> skippedTests = testListenerAdapter.getSkippedTests(); if (!skippedTests.isEmpty()) { System.out.println("Skipped tests: " + skippedTests); for (ITestResult skippedTest : skippedTests) { System.out.println(skippedTest.getName() + ": " + skippedTest.getThrowable()); } success = false; } List<ITestResult> failedTests = testListenerAdapter.getFailedTests(); if (!failedTests.isEmpty()) { System.err.println("Failed tests: " + failedTests); for (ITestResult failedTest : failedTests) { System.out.println(failedTest.getName() + ": " + failedTest.getThrowable()); } success = false; } if (success) { System.exit(0); } else { System.exit(1); } }
Example #9
Source File: CarinaListener.java From carina with Apache License 2.0 | 4 votes |
private void checkHealth(ISuite suite, String className, String[] methods) { if (className.isEmpty()) { return; } // create runtime XML suite for health check XmlSuite xmlSuite = new XmlSuite(); xmlSuite.setName("HealthCheck XmlSuite - " + className); XmlTest xmlTest = new XmlTest(xmlSuite); xmlTest.setName("HealthCheck TestCase"); XmlClass xmlHealthCheckClass = new XmlClass(); xmlHealthCheckClass.setName(className); // TestNG do not execute missed methods so we have to calulate expected // methods count to handle potential mistakes in methods naming int expectedMethodsCount = -1; if (methods != null) { // declare particular methods if they are provided List<XmlInclude> methodsToRun = constructIncludes(methods); expectedMethodsCount = methodsToRun.size(); xmlHealthCheckClass.setIncludedMethods(methodsToRun); } xmlTest.setXmlClasses(Arrays.asList(new XmlClass[] { xmlHealthCheckClass })); xmlSuite.setTests(Arrays.asList(new XmlTest[] { xmlTest })); LOGGER.info("HealthCheck '" + className + "' is started."); LOGGER.debug("HealthCheck suite content:" + xmlSuite.toXml()); // Second TestNG process to run HealthCheck TestNG testng = new TestNG(); testng.setXmlSuites(Arrays.asList(xmlSuite)); TestListenerAdapter tla = new TestListenerAdapter(); testng.addListener(tla); testng.run(); synchronized (this) { boolean passed = false; if (expectedMethodsCount == -1) { if (tla.getPassedTests().size() > 0 && tla.getFailedTests().size() == 0 && tla.getSkippedTests().size() == 0) { passed = true; } } else { LOGGER.info("Expected passed tests count: " + expectedMethodsCount); if (tla.getPassedTests().size() == expectedMethodsCount && tla.getFailedTests().size() == 0 && tla.getSkippedTests().size() == 0) { passed = true; } } if (passed) { LOGGER.info("HealthCheck suite '" + className + "' is finished successfully."); } else { throw new SkipException("Skip test(s) due to health check failures for '" + className + "'"); } } }