本文整理汇总了Java中org.testng.TestNG.run方法的典型用法代码示例。如果您正苦于以下问题:Java TestNG.run方法的具体用法?Java TestNG.run怎么用?Java TestNG.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.testng.TestNG
的用法示例。
在下文中一共展示了TestNG.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.testng.TestNG; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
resultsDir = folder.newFolder();
AllureResultsUtils.setResultsDirectory(resultsDir);
List<String> suites = new ArrayList<>();
URL resource = getClass().getClassLoader().getResource("suite3.xml");
assertNotNull("could not find suite3.xml", resource);
//noinspection ConstantConditions
suites.add(resource.getFile());
TestNG testNG = new TestNG();
testNG.setTestSuites(suites);
testNG.setUseDefaultListeners(false);
testNG.run();
}
示例2: verifyHappyPath
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyHappyPath() {
ListenerChain lc = new ListenerChain();
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
testNG.addListener((ITestNGListener) lc);
testNG.addListener((ITestNGListener) tla);
testNG.setGroups("testPassed");
testNG.run();
assertEquals(tla.getPassedTests().size(), 1, "Incorrect passed test count");
assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
ITestResult result = tla.getPassedTests().get(0);
assertNull(UnitTestArtifact.getCaptureState(result), "Artifact provider capture state should be 'null'");
assertNull(UnitTestCapture.getArtifactPath(result), "Artifact capture should not have been requested");
}
示例3: verifyCaptureOnFailure
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyCaptureOnFailure() {
ListenerChain lc = new ListenerChain();
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
testNG.addListener((ITestNGListener) lc);
testNG.addListener((ITestNGListener) tla);
testNG.setGroups("testFailed");
testNG.run();
assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
assertEquals(tla.getFailedTests().size(), 1, "Incorrect failed test count");
assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
ITestResult result = tla.getFailedTests().get(0);
assertEquals(UnitTestArtifact.getCaptureState(result), CaptureState.CAPTURE_SUCCESS, "Incorrect artifact provider capture state");
assertTrue(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path is not present");
}
示例4: verifyOnDemandCapture
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyOnDemandCapture() {
ListenerChain lc = new ListenerChain();
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
testNG.addListener((ITestNGListener) lc);
testNG.addListener((ITestNGListener) tla);
testNG.setGroups("onDemandCapture");
testNG.run();
assertEquals(tla.getPassedTests().size(), 1, "Incorrect passed test count");
assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
ITestResult result = tla.getPassedTests().get(0);
assertEquals(UnitTestArtifact.getCaptureState(result), CaptureState.CAPTURE_SUCCESS, "Incorrect artifact provider capture state");
assertTrue(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path is not present");
}
示例5: testAttributeHandOff
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void testAttributeHandOff() {
ExecutionFlowController efc = new ExecutionFlowController();
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[]{HappyPathClass.class});
testNG.addListener((ITestNGListener) efc);
testNG.addListener((ITestNGListener) tla);
testNG.run();
assertEquals(tla.getFailedTests().size(), 0, "Unexpected test method failure");
assertEquals(tla.getConfigurationFailures().size(), 0, "Unexpected configuration method failure");
assertEquals(tla.getPassedTests().size(), 2, "Incorrect passed test count");
assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
assertEquals(HappyPathClass.fromBefore, HappyPathClass.VALUE, "Incorrect [before] value");
assertEquals(HappyPathClass.fromMethod, HappyPathClass.VALUE, "Incorrect [method] value");
assertEquals(HappyPathClass.fromAfter, HappyPathClass.VALUE, "Incorrect [after] value");
}
示例6: testSkipFromMethod
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void testSkipFromMethod() {
ExecutionFlowController efc = new ExecutionFlowController();
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[]{SkipFromMethod.class});
testNG.addListener((ITestNGListener) efc);
testNG.addListener((ITestNGListener) tla);
testNG.run();
assertEquals(tla.getFailedTests().size(), 0, "Unexpected test method failure");
assertEquals(tla.getConfigurationFailures().size(), 0, "Unexpected configuration method failure");
assertEquals(tla.getPassedTests().size(), 1, "Incorrect passed test count");
assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
assertEquals(tla.getSkippedTests().size(), 1, "Incorrect skipped test count");
assertEquals(tla.getSkippedTests().get(0).getName(), "testMethod", "Incorrect skipped test name");
assertEquals(SkipFromMethod.fromBefore, SkipFromMethod.VALUE, "Incorrect [before] value");
assertEquals(SkipFromMethod.fromMethod, SkipFromMethod.VALUE, "Incorrect [method] value");
assertEquals(SkipFromMethod.fromAfter, SkipFromMethod.VALUE, "Incorrect [after] value");
}
示例7: run
import org.testng.TestNG; //导入方法依赖的package包/类
@Override
public void run() {
try {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { HybridTest.class });
//testng.settes
testng.addListener(tla);
testng.run();
}catch (Exception e) {
e.printStackTrace();
System.out.println("Thread " + threadName + " interrupted.");
}
System.out.println("Thread " + threadName + " exiting.");
}
示例8: runTestAndAssertCounters
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void runTestAndAssertCounters() throws Exception {
final TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
final TestNG testNG = new TestNG();
testNG.addListener(listener);
testNG.setTestClasses(new Class<?>[] { this.clazz });
testNG.setVerbose(0);
testNG.run();
assertEquals("Verifying number of test starts for test class [" + this.clazz + "].",
this.expectedTestStartCount, listener.testStartCount);
assertEquals("Verifying number of successful tests for test class [" + this.clazz + "].",
this.expectedTestSuccessCount, listener.testSuccessCount);
assertEquals("Verifying number of failures for test class [" + this.clazz + "].", this.expectedFailureCount,
listener.testFailureCount);
assertEquals("Verifying number of failed configurations for test class [" + this.clazz + "].",
this.expectedFailedConfigurationsCount, listener.failedConfigurationsCount);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:FailingBeforeAndAfterMethodsTestNGTests.java
示例9: runTestClassAndAssertStats
import org.testng.TestNG; //导入方法依赖的package包/类
private void runTestClassAndAssertStats(Class<?> testClass, int expectedTestCount) {
final int expectedTestFailureCount = 0;
final int expectedTestStartedCount = expectedTestCount;
final int expectedTestFinishedCount = expectedTestCount;
final TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
final TestNG testNG = new TestNG();
testNG.addListener(listener);
testNG.setTestClasses(new Class<?>[] { testClass });
testNG.setVerbose(0);
testNG.run();
assertEquals("Failures for test class [" + testClass + "].", expectedTestFailureCount,
listener.testFailureCount);
assertEquals("Tests started for test class [" + testClass + "].", expectedTestStartedCount,
listener.testStartCount);
assertEquals("Successful tests for test class [" + testClass + "].", expectedTestFinishedCount,
listener.testSuccessCount);
}
示例10: run
import org.testng.TestNG; //导入方法依赖的package包/类
private void run()
{
LOG.debug("running tempto with options: {}", options);
if (options.isHelpRequested()) {
parser.printHelpMessage();
return;
}
XmlSuite testSuite = getXmlSuite();
testSuite.setThreadCount(options.getThreadCount());
setupTestsConfiguration();
System.setProperty(CONVENTION_TESTS_DIR_KEY, options.getConventionTestsDirectory());
TestNG testNG = new TestNG();
testNG.setXmlSuites(singletonList(testSuite));
testNG.setOutputDirectory(options.getReportDir());
setupTestsFiltering(testNG);
options.getConventionResultsDumpPath()
.ifPresent(path -> System.setProperty(CONVENTION_TESTS_RESULTS_DUMP_PATH_KEY, path));
testNG.run();
if (testNG.hasFailure()) {
System.exit(1);
}
}
示例11: getExecutableTest
import org.testng.TestNG; //导入方法依赖的package包/类
@Override
public Callable<AnalysisResults> getExecutableTest(final Class<?> test) {
final TestNG core = this.testCore;
return new Callable<AnalysisResults>() {
@Override
public AnalysisResults call() {
try {
core.setTestClasses(new Class[]{test});
core.run();
AnalysisResults results = new AnalysisResults();
//results.put(JUNIT_TEST_RESULT, result);
//results.put(TEST_CLASS_NAME, test.getName());
return results;
// this.printTestRunSummary(); // TODO Move to AbstractRuntimeAnalyzer.runTests.
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
};
}
示例12: runTestAndAssertCounters
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void runTestAndAssertCounters() throws Exception {
final FailureTrackingTestListener listener = new FailureTrackingTestListener();
final TestNG testNG = new TestNG();
testNG.addListener(listener);
testNG.setTestClasses(new Class<?>[] { this.clazz });
testNG.setVerbose(0);
testNG.run();
assertEquals("Verifying number of test starts for test class [" + this.clazz + "].",
this.expectedTestStartCount, listener.testStartCount);
assertEquals("Verifying number of successful tests for test class [" + this.clazz + "].",
this.expectedTestSuccessCount, listener.testSuccessCount);
assertEquals("Verifying number of failures for test class [" + this.clazz + "].", this.expectedFailureCount,
listener.testFailureCount);
assertEquals("Verifying number of failed configurations for test class [" + this.clazz + "].",
this.expectedFailedConfigurationsCount, listener.failedConfigurationsCount);
}
示例13: testRunSampleTestNGClass
import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void testRunSampleTestNGClass() throws Exception {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] {TestSubClass.class});
testng.addListener(tla);
testng.run();
for (String item : this.outputFiles) {
File file = new File(item);
Assert.assertTrue(
"The element '" + file.getAbsolutePath() + "' wasn't found",
file.exists());
}
for (String method : this.expectedMethods) {
Assert.assertTrue(
"Unable to find the call of method: " + method,
AerialGluCode.getCallsList().contains(method));
}
}
示例14: execute
import org.testng.TestNG; //导入方法依赖的package包/类
@Override
public TestExecutionResult execute( Class<?> testClass, String testMethod ) {
TestNgExecutionResult result = new TestNgExecutionResult();
ScenarioTestListenerAdapter testListenerAdapter = new ScenarioTestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses( new Class<?>[] { testClass } );
if( testMethod != null ) {
methodName = testMethod;
testng.addMethodSelector( MethodSelector.class.getName(), 10 );
}
testng.addListener( testListenerAdapter );
Config.config().setReportEnabled( false );
testng.run();
Config.config().setReportEnabled( true );
result.reportModel = testListenerAdapter.reportModel;
result.testResults = testListenerAdapter.testResults;
return result;
}
示例15: reportContainsTestForGroups
import org.testng.TestNG; //导入方法依赖的package包/类
@Test // see https://github.com/allure-framework/allure-core/issues/880
public void reportContainsTestForGroups() {
// GIVEN: an TestNG suite with groups
TestNG testNG = new TestNG(false);
testNG.setTestSuites(singletonList(getClass().getClassLoader().getResource("suite-groups.xml").getFile()));
// WHEN: executing
testNG.run();
// THEN: report only contains results for included groups
List<File> files = listTestSuiteFiles(resultsDir);
assertThat(files, hasSize(1));
File file = files.get(0);
TestSuiteResult result = unmarshal(file, TestSuiteResult.class);
assertThat(result.getTestCases(), hasSize(2));
List<String> status = new ArrayList<>();
for (TestCaseResult test : result.getTestCases()) {
status.add(test.getName() + ":" + test.getStatus());
}
assertThat(status, containsInAnyOrder("inactiveIncludedTest:PENDING", "activeIncludedTest:PASSED"));
}