当前位置: 首页>>代码示例>>Java>>正文


Java TestNG.setTestClasses方法代码示例

本文整理汇总了Java中org.testng.TestNG.setTestClasses方法的典型用法代码示例。如果您正苦于以下问题:Java TestNG.setTestClasses方法的具体用法?Java TestNG.setTestClasses怎么用?Java TestNG.setTestClasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.testng.TestNG的用法示例。


在下文中一共展示了TestNG.setTestClasses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例2: verifyCanNotCapture

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyCanNotCapture() {
    
    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("canNotCapture");
    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.CAN_NOT_CAPTURE, "Incorrect artifact provider capture state");
    assertFalse(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path should not be present");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例3: verifyWillNotCapture

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyWillNotCapture() {
    
    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("willNotCapture");
    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_FAILED, "Incorrect artifact provider capture state");
    assertFalse(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path should not be present");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例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");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例5: 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");
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:26,代码来源:ExecutionFlowControllerTest.java

示例6: 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.");
}
 
开发者ID:mattecker,项目名称:revature-automation-framework-remastered,代码行数:18,代码来源:TestThread.java

示例7: 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

示例8: 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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:ClassLevelDirtiesContextTestNGTests.java

示例9: 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;
				
			}
		};
	}
 
开发者ID:spideruci,项目名称:tacoco,代码行数:26,代码来源:TestNGRunner.java

示例10: 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);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:19,代码来源:FailingBeforeAndAfterMethodsTests.java

示例11: 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));
    }
}
 
开发者ID:mkolisnyk,项目名称:aerial,代码行数:21,代码来源:AerialTestNGRunnerTest.java

示例12: 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;
}
 
开发者ID:TNG,项目名称:JGiven,代码行数:19,代码来源:TestNgExecutor.java

示例13: runTests

import org.testng.TestNG; //导入方法依赖的package包/类
private void runTests() {
    TestNG testNg = new TestNG();
    testNg.setOutputDirectory(testReportDir.getAbsolutePath());
    testNg.setDefaultSuiteName(options.getDefaultSuiteName());
    testNg.setDefaultTestName(options.getDefaultTestName());
    testNg.setParallel(options.getParallel());
    testNg.setThreadCount(options.getThreadCount());
    invokeVerifiedMethod(testNg, "setConfigFailurePolicy", String.class, options.getConfigFailurePolicy(), TestNGOptions.DEFAULT_CONFIG_FAILURE_POLICY);
    invokeVerifiedMethod(testNg, "setPreserveOrder", boolean.class, options.getPreserveOrder(), false);
    invokeVerifiedMethod(testNg, "setGroupByInstances", boolean.class, options.getGroupByInstances(), false);
    testNg.setUseDefaultListeners(options.getUseDefaultListeners());
    testNg.setVerbose(0);
    testNg.setGroups(CollectionUtils.join(",", options.getIncludeGroups()));
    testNg.setExcludedGroups(CollectionUtils.join(",", options.getExcludeGroups()));

    //adding custom test listeners before Gradle's listeners.
    //this way, custom listeners are more powerful and, for example, they can change test status.
    for (String listenerClass : options.getListeners()) {
        try {
            testNg.addListener(applicationClassLoader.loadClass(listenerClass).newInstance());
        } catch (Throwable e) {
            throw new GradleException(String.format("Could not add a test listener with class '%s'.", listenerClass), e);
        }
    }

    if (!options.getIncludedTests().isEmpty()) {
        testNg.addListener(new SelectedTestsFilter(options.getIncludedTests()));
    }

    if (!suiteFiles.isEmpty()) {
        testNg.setTestSuites(GFileUtils.toPaths(suiteFiles));
    } else {
        testNg.setTestClasses(testClasses.toArray(new Class[0]));
    }
    testNg.addListener((Object) adaptListener(new TestNGTestResultProcessorAdapter(resultProcessor, idGenerator, timeProvider)));
    testNg.run();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:38,代码来源:TestNGTestClassProcessor.java

示例14: main

import org.testng.TestNG; //导入方法依赖的package包/类
@SuppressWarnings("raw_types")
public static void main(String[] args) {
    Class<?>[] testclass = {TreeTest.class};
    TestNG testng = new TestNG();
    testng.setTestClasses(testclass);
    testng.run();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TreeTest.java

示例15: main

import org.testng.TestNG; //导入方法依赖的package包/类
@SuppressWarnings("raw_types")
@Test(enabled = false)
public static void main(String[] args) {
    Class<?>[] testclass = {SunMiscSignalTest.class};
    TestNG testng = new TestNG();
    testng.setTestClasses(testclass);
    testng.run();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SunMiscSignalTest.java


注:本文中的org.testng.TestNG.setTestClasses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。