org.testng.TestNG.setVerbose()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中org.testng.TestNG.setVerbose()方法的一些代码示例,展示了TestNG.setVerbose()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestNG.setVerbose()方法的具体详情如下:
包路径:org.testng.TestNG
类名称:TestNG
方法名:setVerbose

TestNG.setVerbose介绍

[英]Sets the level of verbosity. This value will override the value specified in the test suites.
[中]设置详细程度。该值将覆盖测试套件中指定的值。

代码示例

代码示例来源:origin: cbeust/testng

@BeforeMethod
public void setUp() {
 m_testNg = new TestNG();
 m_testNg.setVerbose(0);
}

代码示例来源:origin: cbeust/testng

private static TestNG createTestNG(Path outputDir) {
 TestNG result = new TestNG();
 result.setOutputDirectory(outputDir.toAbsolutePath().toString());
 result.setVerbose(-1);
 return result;
}

代码示例来源:origin: cbeust/testng

@Test(expectedExceptions = TestNGException.class,
      expectedExceptionsMessageRegExp = ".*Check to make sure it can be instantiated",
      description = "GITHUB-1827")
  public void ensureExceptionThrownWhenNoSuitableConstructorFound() {

    TestNG testng = create(GitHub1827Sample.class);
    testng.setVerbose(3);
    testng.run();
  }
}

代码示例来源:origin: cbeust/testng

@Test
public void ensureTestClassInstantiationWorksWhenFactoryMethodAndCustomConstructorPresent() {
 TestNG testng = create(TestclassSample.class);
 testng.setVerbose(2);
 testng.run();
 List<String> expected = Arrays.asList("1", "2");
 assertThat(TestclassSample.logs).containsExactlyInAnyOrderElementsOf(expected);
}

代码示例来源:origin: cbeust/testng

@Test
public void withFactory() {
 TestNG tng = new TestNG();
 tng.setVerbose(0);
 tng.setTestClasses(new Class[] { MyFactory.class});
 FactoryTest.m_count = 0;
 tng.run();
 assertEquals(FactoryTest.m_count, 4);
}

代码示例来源:origin: cbeust/testng

public static TestNG create() {
 TestNG result = new TestNG();
 result.setUseDefaultListeners(false);
 result.setVerbose(0);
 return result;
}

代码示例来源:origin: cbeust/testng

@Test
 public void test() {
  TestNG testng = create(ArrayEmptyFactorySample.class, IteratorEmptyFactorySample.class);

  TestListenerAdapter tla = new TestListenerAdapter();
  testng.addListener(tla);
  // Used to check the warning message
  testng.setVerbose(2);

  testng.run();

  Assert.assertTrue(tla.getFailedTests().isEmpty());
  Assert.assertTrue(tla.getSkippedTests().isEmpty());
  Assert.assertTrue(tla.getPassedTests().isEmpty());
 }
}

代码示例来源:origin: cbeust/testng

@Test
public void verifyListenerAnnotationTransformerClass() {
 MySuiteListener.triggered = false;
 MySuiteListener2.triggered = false;
 TestNG tng = new TestNG();
 tng.setVerbose(0);
 tng.addListener(new MyListenerTransformer());
 tng.setTestClasses(new Class[] {AnnotationTransformerClassSampleTest.class});
 tng.run();
 Assert.assertFalse(MySuiteListener.triggered);
 Assert.assertTrue(MySuiteListener2.triggered);
}

代码示例来源:origin: cbeust/testng

@Test
 public void testBeforeAfterClassInvocationsWithFactory() {
  TestNG testng= new TestNG();
  testng.setTestClasses(new Class[] {XClassOrderWithFactory.class});
  TestListenerAdapter tla = new TestListenerAdapter();
  testng.addListener(tla);
  testng.setVerbose(0);
  testng.run();
  Assert.assertEquals(XClassOrderWithFactory.LOG.toString(), XClassOrderWithFactory.EXPECTED_LOG);
 }
}

代码示例来源:origin: cbeust/testng

protected static TestNG run(TestNG result, Class<?>[] classes, String outputDir) {
 result.setVerbose(0);
 result.setOutputDirectory(outputDir);
 result.setTestClasses(classes);
 result.run();
 return result;
}

代码示例来源:origin: cbeust/testng

@Test
public void testAfter() {
 TestNG tng = new TestNG();
 tng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
 tng.setTestClasses(new Class[] { TestAfter1.class, TestAfter2.class });
 tng.setVerbose(0);
 tng.run();
 Assert.assertEquals(BaseAfter.m_afterCount, 1);
}

代码示例来源:origin: cbeust/testng

@BeforeMethod
public void init() {
 m_tng = new TestNG();
 m_tng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
 m_tng.setVerbose(0);
 m_tng.setUseDefaultListeners(false);
}

代码示例来源:origin: cbeust/testng

@Test(description = "GITHUB-1790")
 public void ensureAnnotationTransformerInvokedForClassLevelTestAnnotations() {
  TestNG testng = create(TestClassSample1.class, TestClassSample2.class);
  TransformerImpl transformer = new TransformerImpl();
  testng.addListener(transformer);
  testng.setVerbose(2);
  testng.run();
  assertThat(transformer.getClasses()).hasSize(2);
  assertThat(transformer.getConstructors()).isEmpty();
  assertThat(transformer.getMethods()).hasSize(2);
 }
}

代码示例来源:origin: cbeust/testng

@Test(dataProvider = "dp")
public void testListenerInvocation(Class<?> clazz, XmlSuite.FailurePolicy policy, List<String> expected) {
  TestNG tng = create(clazz);
  ListenerForIssue1602 listener = new ListenerForIssue1602();
  tng.setConfigFailurePolicy(policy);
  tng.setVerbose(2);
  tng.addListener(listener);
  tng.run();
  assertThat(listener.getLogs()).containsExactlyElementsOf(expected);
}

代码示例来源:origin: cbeust/testng

@Test
public void verifyConfigurationTransformer() {
 TestNG tng = new TestNG();
 tng.addListener(new ConfigurationTransformer());
 tng.setVerbose(0);
 tng.setTestClasses(new Class[] {ConfigurationSampleTest.class});
 TestListenerAdapter tla = new TestListenerAdapter();
 tng.addListener(tla);
 tng.run();
 Assert.assertEquals(ConfigurationSampleTest.getBefore(), "correct");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@Ignore("Fails against TestNG 6.11")
public void runTestAndAssertCounters() throws Exception {
  TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
  TestNG testNG = new TestNG();
  testNG.addListener((ITestNGListener) listener);
  testNG.setTestClasses(new Class<?>[] {this.clazz});
  testNG.setVerbose(0);
  testNG.run();
  String name = this.clazz.getSimpleName();
  assertEquals("tests started for [" + name + "] ==> ", this.expectedTestStartCount, listener.testStartCount);
  assertEquals("successful tests for [" + name + "] ==> ", this.expectedTestSuccessCount, listener.testSuccessCount);
  assertEquals("failed tests for [" + name + "] ==> ", this.expectedFailureCount, listener.testFailureCount);
  assertEquals("failed configurations for [" + name + "] ==> ",
      this.expectedFailedConfigurationsCount, listener.failedConfigurationsCount);
}

代码示例来源:origin: spring-projects/spring-framework

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((ITestNGListener) 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);
}

代码示例来源:origin: cbeust/testng

@Test(dataProvider = "dp1")
public void testThreadAffinity(Class<?>... classes) {
 XmlSuite xmlsuite = createXmlSuite("test_suite");
 xmlsuite.setParallel(XmlSuite.ParallelMode.CLASSES);
 xmlsuite.setThreadCount(6);
 createXmlTest(xmlsuite, "Test 1", classes);
 TestNG testng = create(xmlsuite);
 testng.setVerbose(2);
 LogGatheringListener listener = new LogGatheringListener();
 testng.addListener(listener);
 testng.run();
 assertThat(listener.log).hasSize(2);
}

代码示例来源:origin: cbeust/testng

private static void runTest(Class<?>... classes) {
 TestListenerAdapter tla = new TestListenerAdapter();
 TestNG testng = create(classes);
 testng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
 testng.addListener(tla);
 testng.setVerbose(0);
 testng.run();
}

代码示例来源:origin: cbeust/testng

@Test(dataProvider = "dp2")
public void testThreadAffinityAcrossTests(XmlSuite.ParallelMode mode, int size) {
 XmlSuite xmlsuite = createXmlSuite("test_suite");
 xmlsuite.setParallel(XmlSuite.ParallelMode.TESTS);
 xmlsuite.setThreadCount(6);
 createXmlTest(xmlsuite, "Test_1", PriorityTestSample1.class,PriorityTestSample2.class).setParallel(mode);
 createXmlTest(xmlsuite, "Test_2", PriorityTestSample1.class,PriorityTestSample2.class).setParallel(mode);
 TestNG testng = create(xmlsuite);
 testng.setVerbose(2);
 LogGatheringListener listener = new LogGatheringListener();
 testng.addListener(listener);
 testng.run();
 assertThat(listener.log).hasSize(size);
}

相关文章

TestNG类方法