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

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

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

TestNG.privateMain介绍

[英]Note: this method is not part of the public API and is meant for internal usage only.
[中]注意:此方法不是公共API的一部分,仅供内部使用。

代码示例

代码示例来源:origin: org.testng/testng

/**
 * The TestNG entry point for command line execution.
 *
 * @param argv the TestNG command line parameters.
 * @throws FileNotFoundException
 */
public static void main(String[] argv) {
 TestNG testng = privateMain(argv, null);
 System.exit(testng.getStatus());
}

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

/**
 * The TestNG entry point for command line execution.
 *
 * @param argv the TestNG command line parameters.
 */
public static void main(String[] argv) {
 TestNG testng = privateMain(argv, null);
 System.exit(testng.getStatus());
}

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

@Test
public void testUseDefaultListenersArgument() {
 TestNG.privateMain(new String[] {
   "-log", "0", "-usedefaultlisteners", "false", "-testclass", "test.sample.JUnitSample1"
 }, null);
}

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

@Test(description = "GITHUB-1810")
public void ensureNoNullPointerExceptionIsThrown() throws IOException {
 TestNG testng = TestNG.privateMain(new String[] {createTemporarySuiteAndGetItsPath()}, null);
 assertThat(testng.getStatus()).isEqualTo(8);
}

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

@Test
public void mixedClasses() {
  String[] argv = {
    "-d", OutputDirectoryPatch.getOutputDirectory(),
    "-log", "0",
    "-mixed",
    "-testclass", "test.mixed.JUnit3Test1,test.mixed.JUnit4Test1,test.mixed.TestNGTest1"
  };
  TestListenerAdapter tla = new TestListenerAdapter();
  TestNG.privateMain(argv, tla);
  Assert.assertEquals(tla.getPassedTests().size(), 6);
  Assert.assertEquals(tla.getFailedTests().size(), 0);
}

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

@Test(description = "GITHUB-341")
public void ensureParallelismIsHonoredWhenOnlyClassesSpecifiedInJar() throws IOException {
 Class<?>[] classes = new Class<?>[] {TestSampleA.class, TestSampleB.class};
 File jarfile = JarCreator.generateJar(classes);
 String[] args =
   new String[] {
    "-parallel",
    "classes",
    "-testjar",
    jarfile.getAbsolutePath(),
    "-listener",
    LocalLogAggregator.class.getCanonicalName()
   };
 TestNG.privateMain(args, null);
 Set<String> logs = LocalLogAggregator.getLogs();
 assertThat(logs).hasSize(2);
}

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

/**
 * Test the absence of -junit
 */
@Test(groups = { "current" } )
public void junitParsing2() {
 String[] argv = {
  "-log", "0",
  "-d", OutputDirectoryPatch.getOutputDirectory(),
  "-testclass", "test.sample.JUnitSample1"
 };
 TestListenerAdapter tla = new TestListenerAdapter();
 TestNG.privateMain(argv, tla);
 List<ITestResult> passed = tla.getPassedTests();
 assertEquals(passed.size(), 0);
 }

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

@Test
  public void mixedMethods() {
    String[] argv = {
      "-d", OutputDirectoryPatch.getOutputDirectory(),
      "-mixed",
      "-log", "0",
      "-methods", "test.mixed.JUnit3Test1.testB,test.mixed.JUnit4Test1.atest,test.mixed.TestNGTest1.tngCustomTest1"
    };
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG.privateMain(argv, tla);

    Assert.assertEquals(tla.getPassedTests().size(), 3);
    Assert.assertEquals(tla.getFailedTests().size(), 0);
  }
}

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

@Test
public void mixedWithExcludedGroups() {
  String[] argv = {
      "-d", OutputDirectoryPatch.getOutputDirectory(),
      "-log", "0",
      "-mixed",
      "-groups", "unit",
      "-excludegroups", "ignore",
      "-testclass", "test.mixed.JUnit3Test1,test.mixed.JUnit4Test1,test.mixed.TestNGTest1,test.mixed.TestNGGroups"
  };
  TestListenerAdapter tla = new TestListenerAdapter();
  TestNG.privateMain(argv, tla);
  Assert.assertEquals(tla.getPassedTests().size(), 5); //2 from junit3test1, 2 from junit4test1, 0 from testngtest1 (no groups), 1 from testnggroups (1 is included, 1 is excluded)
  Assert.assertEquals(tla.getFailedTests().size(), 0);
}

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

@Test
public void fileOnCommandLine() {
 String[] args = new String[] {
   "-d", OutputDirectoryPatch.getOutputDirectory(),
   getPathToResource("methodselector-in-xml.xml") };
 TestNG.privateMain(args, m_tla);
 validate(new String[] { "test2" });
}

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

@Test
public void commandLineTestWithXMLFile_policyAsContinue() {
 String[] argv =
   new String[] {
    "-log",
    "0",
    "-d",
    OutputDirectoryPatch.getOutputDirectory(),
    "-configfailurepolicy",
    "continue",
    getPathToResource("testng-configfailure.xml")
   };
 TestListenerAdapter tla = new TestListenerAdapter();
 TestNG.privateMain(argv, tla);
 verify(tla, 2, 0, 2);
}

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

@Test
public void commandLineTestWithXMLFile_policyAsSkip() {
 String[] argv =
   new String[] {
    "-log",
    "0",
    "-d",
    OutputDirectoryPatch.getOutputDirectory(),
    "-configfailurepolicy",
    "skip",
    getPathToResource("testng-configfailure.xml")
   };
 TestListenerAdapter tla = new TestListenerAdapter();
 TestNG.privateMain(argv, tla);
 verify(tla, 1, 1, 2);
}

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

@Test
public void commandLineNegativePriorityAllGroups() {
 ppp("commandLineNegativePriorityAllGroups()");
 ARG_WITHOUT_GROUPS[7] = "test.methodselectors.AllTestsMethodSelector:-1";
 TestNG.privateMain(ARG_WITHOUT_GROUPS, tla);
 String[] passed = {
   "test1", "test2", "test3"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}

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

@Test
public void commandLineNegativePriorityGroup2() {
 ppp("commandLineNegativePriorityGroup2()");
 ARG_WITHOUT_GROUPS[7] = "test.methodselectors.Test2MethodSelector:-1";
 TestNG.privateMain(ARG_WITHOUT_GROUPS, tla);
 String[] passed = {
   "test2"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}

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

@Test
public void commandLineNoTest1Selector() {
 ppp("commandLineNoTest1Selector()");
 ARG_WITHOUT_GROUPS[7] = "test.methodselectors.NoTest1MethodSelector:5";
 TestNG.privateMain(ARG_WITHOUT_GROUPS, tla);
 String[] passed = {
   "test2", "test3"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}

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

@Test
public void commandLineMultipleSelectors() {
 ppp("commandLineMultipleSelectors()");
 ARG_WITH_GROUPS[7] = "test.methodselectors.NoTestSelector:7,test.methodselectors.Test2MethodSelector:5";
 ARG_WITH_GROUPS[9] = "test1";
 TestNG.privateMain(ARG_WITH_GROUPS, tla);
 String[] passed = {
   "test1", "test2"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}

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

@Test
public void commandLineLessThanPriorityTest1Test() {
 ppp("commandLineLessThanPriorityTest1Test()");
 ARG_WITH_GROUPS[7] = "test.methodselectors.Test2MethodSelector:5";
 ARG_WITH_GROUPS[9] = "test1";
 TestNG.privateMain(ARG_WITH_GROUPS, tla);
 String[] passed = {
   "test1", "test2"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}

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

@Test
public void commandLineLessThanPriorityAllTests() {
 ppp("commandLineLessThanPriorityAllTests()");
 ARG_WITH_GROUPS[7] = "test.methodselectors.AllTestsMethodSelector:5";
 ARG_WITH_GROUPS[9] = "test1";
 TestNG.privateMain(ARG_WITH_GROUPS, tla);
 String[] passed = {
   "test1", "test2", "test3"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}

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

@Test
public void commandLineGreaterThanPriorityTest1Test2() {
 ppp("commandLineGreaterThanPriorityTest1Test2()");
 ARG_WITH_GROUPS[7] = "test.methodselectors.Test2MethodSelector:15";
 ARG_WITH_GROUPS[9] = "test1";
 TestNG.privateMain(ARG_WITH_GROUPS, tla);
 String[] passed = {
   "test2"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}
@Test

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

@Test
public void commandLineTestWithXmlFile() {
 ppp("commandLineTestWithXmlFile()");
 ARG_WITHOUT_CLASSES[5] = "test.methodselectors.NoTest1MethodSelector:5";
 ARG_WITHOUT_CLASSES[6] = getPathToResource("testng-methodselectors.xml");
 TestNG.privateMain(ARG_WITHOUT_CLASSES, tla);
 String[] passed = {
   "test2", "test3"
 };
 String[] failed = {
 };
 verifyTests("Passed", passed, tla.getPassedTests());
 verifyTests("Failed", failed, tla.getFailedTests());
}

相关文章

TestNG类方法