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


Java TestNG.setGroups方法代码示例

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


在下文中一共展示了TestNG.setGroups方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

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

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

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

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

示例7: verifyTestFailed

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyTestFailed() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ListenerChainTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("testFailed");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    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");
    
    assertTrue(chainedListener.configSuccess.contains("beforeSuccess"));
    assertTrue(chainedListener.configSuccess.contains("afterSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("afterSuccess"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeSuccess"));
    assertTrue(chainedListener.testMethodBefore.contains("testFailed"));
    assertTrue(chainedListener.testMethodAfter.contains("testFailed"));
    assertTrue(chainedListener.afterMethodBefore.contains("afterSuccess"));
    assertTrue(chainedListener.afterMethodAfter.contains("afterSuccess"));
    
    assertTrue(chainedListener.testStarted.contains("testFailed"));
    assertTrue(chainedListener.testFailure.contains("testFailed"));
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:39,代码来源:ListenerChainTest.java

示例8: verifyTestSkipped

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyTestSkipped() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ListenerChainTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("testSkipped");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 1, "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");
    
    assertTrue(chainedListener.configSuccess.contains("beforeSuccess"));
    assertTrue(chainedListener.configSuccess.contains("afterSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("afterSuccess"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeSuccess"));
    assertTrue(chainedListener.testMethodBefore.contains("testSkipped"));
    assertTrue(chainedListener.testMethodAfter.contains("testSkipped"));
    assertTrue(chainedListener.afterMethodBefore.contains("afterSuccess"));
    assertTrue(chainedListener.afterMethodAfter.contains("afterSuccess"));
    
    assertTrue(chainedListener.testStarted.contains("testSkipped"));
    assertTrue(chainedListener.testSkipped.contains("testSkipped"));
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:39,代码来源:ListenerChainTest.java

示例9: verifyFailAndPass

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyFailAndPass() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ListenerChainTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("failAndPass");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    assertEquals(tla.getPassedTests().size(), 3, "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(), 1, "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");
    
    assertTrue(chainedListener.configSuccess.contains("beforeSuccess"));
    assertTrue(chainedListener.configSuccess.contains("afterSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("afterSuccess"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeSuccess"));
    assertTrue(chainedListener.testMethodBefore.contains("failAndPass"));
    assertTrue(chainedListener.testMethodAfter.contains("failAndPass"));
    assertTrue(chainedListener.afterMethodBefore.contains("afterSuccess"));
    assertTrue(chainedListener.afterMethodAfter.contains("afterSuccess"));
    
    assertTrue(chainedListener.testStarted.contains("failAndPass"));
    assertTrue(chainedListener.testCurved.contains("failAndPass"));
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:39,代码来源:ListenerChainTest.java

示例10: verifyBeforeFailed

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyBeforeFailed() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ListenerChainTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("beforeFailed");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 1, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 1, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 1, "Incorrect configuration method skip count");
    
    assertTrue(chainedListener.configFailure.contains("beforeFailure"));
    assertTrue(chainedListener.configSkipped.contains("afterSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("beforeFailure"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeFailure"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeFailure"));
    assertTrue(chainedListener.testMethodBefore.contains("skipBeforeFailed"));
    assertTrue(chainedListener.testMethodAfter.contains("skipBeforeFailed"));
    
    assertTrue(chainedListener.testStarted.contains("skipBeforeFailed"));
    assertTrue(chainedListener.testSkipped.contains("skipBeforeFailed"));
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:36,代码来源:ListenerChainTest.java

示例11: verifyBeforeSkipped

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyBeforeSkipped() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ListenerChainTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("beforeSkipped");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 1, "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(), 2, "Incorrect configuration method skip count");
    
    assertTrue(chainedListener.configSkipped.contains("beforeSkipped"));
    assertTrue(chainedListener.configSkipped.contains("afterSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("beforeSkipped"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeSkipped"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeSkipped"));
    assertTrue(chainedListener.testMethodBefore.contains("skipBeforeSkipped"));
    assertTrue(chainedListener.testMethodAfter.contains("skipBeforeSkipped"));
    
    assertTrue(chainedListener.testStarted.contains("skipBeforeSkipped"));
    assertTrue(chainedListener.testSkipped.contains("skipBeforeSkipped"));
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:36,代码来源:ListenerChainTest.java

示例12: verifyAfterFailed

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyAfterFailed() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ListenerChainTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("afterFailed");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    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(), 1, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    assertTrue(chainedListener.configSuccess.contains("beforeSuccess"));
    assertTrue(chainedListener.configFailure.contains("afterFailure"));
    assertTrue(chainedListener.beforeConfig.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("afterFailure"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeSuccess"));
    assertTrue(chainedListener.testMethodBefore.contains("testAfterFailed"));
    assertTrue(chainedListener.testMethodAfter.contains("testAfterFailed"));
    assertTrue(chainedListener.afterMethodBefore.contains("afterFailure"));
    assertTrue(chainedListener.afterMethodAfter.contains("afterFailure"));
    
    assertTrue(chainedListener.testStarted.contains("testAfterFailed"));
    assertTrue(chainedListener.testSuccess.contains("testAfterFailed"));
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:39,代码来源:ListenerChainTest.java

示例13: verifyAfterSkipped

import org.testng.TestNG; //导入方法依赖的package包/类
@Test
public void verifyAfterSkipped() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ListenerChainTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("afterSkipped");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    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(), 1, "Incorrect configuration method skip count");
    
    assertTrue(chainedListener.configSuccess.contains("beforeSuccess"));
    assertTrue(chainedListener.configSkipped.contains("afterSkipped"));
    assertTrue(chainedListener.beforeConfig.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("afterSkipped"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeSuccess"));
    assertTrue(chainedListener.testMethodBefore.contains("testAfterSkipped"));
    assertTrue(chainedListener.testMethodAfter.contains("testAfterSkipped"));
    assertTrue(chainedListener.afterMethodBefore.contains("afterSkipped"));
    assertTrue(chainedListener.afterMethodAfter.contains("afterSkipped"));
    
    assertTrue(chainedListener.testStarted.contains("testAfterSkipped"));
    assertTrue(chainedListener.testSuccess.contains("testAfterSkipped"));
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:39,代码来源:ListenerChainTest.java

示例14: 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[]{ListenerChainTestCases.class, ListenerChainTestFactory.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("happyPath");
    testNG.run();
    
    ChainedListener chainedListener = lc.getAttachedListener(ChainedListener.class).get();
    
    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(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");
    
    assertTrue(chainedListener.configSuccess.contains("beforeSuccess"));
    assertTrue(chainedListener.configSuccess.contains("afterSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeConfig.contains("afterSuccess"));
    
    assertTrue(chainedListener.beforeMethodBefore.contains("beforeSuccess"));
    assertTrue(chainedListener.beforeMethodAfter.contains("beforeSuccess"));
    assertTrue(chainedListener.testMethodBefore.contains("happyPath"));
    assertTrue(chainedListener.testMethodAfter.contains("happyPath"));
    assertTrue(chainedListener.afterMethodBefore.contains("afterSuccess"));
    assertTrue(chainedListener.afterMethodAfter.contains("afterSuccess"));
    
    assertTrue(chainedListener.testStarted.contains("happyPath"));
    assertTrue(chainedListener.testSuccess.contains("happyPath"));
    
    assertTrue(chainedListener.beforeClass.contains("ListenerChainTestCases"));
    assertTrue(chainedListener.afterClass.contains("ListenerChainTestCases"));
    
    assertTrue(chainedListener.testsBegun.contains("Command line test"));
    assertTrue(chainedListener.testsEnded.contains("Command line test"));
    
    assertTrue(chainedListener.suiteBegun.contains("Command line suite"));
    assertTrue(chainedListener.suiteEnded.contains("Command line suite"));
    
    Set<String> expectTests = new HashSet<>(Arrays.asList("method: testSkipped",
                    "method: happyPath", "method: beforeSuccess", "method: beforeSkipped",
                    "method: skipBeforeFailed", "method: skipBeforeSkipped",
                    "method: testAfterSkipped", "method: productTest", "method: failAndPass",
                    "method: afterSuccess", "method: afterFailure",
                    "class: ListenerChainTestCases", "method: testAfterFailed",
                    "method: beforeFailure", "method: afterSkipped", "method: testFailed",
                    "method: testAttachedListeners"));
    Set<String> expectConfigs = new HashSet<>(Arrays.asList("method: afterSuccess",
                    "method: afterFailure", "method: beforeSuccess", "method: beforeFailure",
                    "method: beforeSkipped", "method: afterSkipped"));
    
    assertEquals(chainedListener.xformTest, expectTests);
    assertEquals(chainedListener.xformConfig, expectConfigs);
    assertTrue(chainedListener.xformProvider.contains("method: dataProvider"));
    assertTrue(chainedListener.xformFactory.contains("method: createInstances"));
    assertTrue(chainedListener.xformListeners.contains("class: ListenerChainTestCases"));
    
    assertTrue(chainedListener.interceptor.contains("Command line test"));
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:67,代码来源:ListenerChainTest.java


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