下面列出了怎么用org.testng.annotations.AfterGroups的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Test cleanup
*
*/
@AfterGroups(groups = {"rest-commands"}, alwaysRun = true)
//@Test(alwaysRun = true)
public static void stopPayara() {
final String METHOD = "stopPayara";
LOGGER.log(Level.INFO, METHOD, "stopFrame");
LOGGER.log(Level.INFO, METHOD, "stopText");
LOGGER.log(Level.INFO, METHOD, "stopFrame");
PayaraServer server = payaraServer();
try {
ResultString result = CommandStopDAS.stopDAS(server);
gfStdOut.close();
gfStdErr.close();
assertEquals(result.getState(), TaskState.COMPLETED);
} catch (PayaraIdeException gfie) {
fail("Version command execution failed: " + gfie.getMessage());
}
}
/**
* Test cleanup
*
*/
@AfterGroups(groups = {"http-commands"})
public static void stopPayara() {
final String METHOD = "stopPayara";
LOGGER.log(Level.INFO, METHOD, "stopFrame");
LOGGER.log(Level.INFO, METHOD, "stopText");
LOGGER.log(Level.INFO, METHOD, "stopFrame");
PayaraServer server = payaraServer();
Command command = new CommandStopDAS();
try {
Future<ResultString> future =
ServerAdmin.<ResultString>exec(server, command);
try {
ResultString result = future.get();
gfStdOut.close();
gfStdErr.close();
assertNotNull(result.getValue());
assertTrue(result.getState() == TaskState.COMPLETED);
} catch (InterruptedException | ExecutionException ie) {
fail("Version command execution failed: " + ie.getMessage());
}
} catch (PayaraIdeException gfie) {
fail("Version command execution failed: " + gfie.getMessage());
}
}
/**
* Test cleanup
*
*/
@AfterGroups(groups = {"rest-commands"}, alwaysRun = true)
//@Test(alwaysRun = true)
public static void stopGlassFish() {
final String METHOD = "stopGlassFish";
LOGGER.log(Level.INFO, METHOD, "stopFrame");
LOGGER.log(Level.INFO, METHOD, "stopText");
LOGGER.log(Level.INFO, METHOD, "stopFrame");
GlassFishServer server = glassFishServer();
try {
ResultString result = CommandStopDAS.stopDAS(server);
gfStdOut.close();
gfStdErr.close();
assertEquals(result.getState(), TaskState.COMPLETED);
} catch (GlassFishIdeException gfie) {
fail("Version command execution failed: " + gfie.getMessage());
}
}
/**
* Test cleanup
*
*/
@AfterGroups(groups = {"http-commands"})
public static void stopGlassFish() {
final String METHOD = "stopGlassFish";
LOGGER.log(Level.INFO, METHOD, "stopFrame");
LOGGER.log(Level.INFO, METHOD, "stopText");
LOGGER.log(Level.INFO, METHOD, "stopFrame");
GlassFishServer server = glassFishServer();
Command command = new CommandStopDAS();
try {
Future<ResultString> future =
ServerAdmin.<ResultString>exec(server, command);
try {
ResultString result = future.get();
gfStdOut.close();
gfStdErr.close();
assertNotNull(result.getValue());
assertTrue(result.getState() == TaskState.COMPLETED);
} catch (InterruptedException | ExecutionException ie) {
fail("Version command execution failed: " + ie.getMessage());
}
} catch (GlassFishIdeException gfie) {
fail("Version command execution failed: " + gfie.getMessage());
}
}
@AfterGroups("StreamReading")
public void closeStreams() throws IOException {
System.setErr(originalErrorStream);
System.setOut(originalOutStream);
errPrintStream.close();
outPrintStream.close();
}
@AfterGroups(groups = "sharedHBase")
public void afterGroups(ITestContext context) throws Exception {
LOG.info("Tearing down OmidTestBase...");
if (hbaseCluster != null) {
hBaseUtils.shutdownMiniCluster();
}
getClient(context).close().get();
getTSO(context).stopAndWait();
TestUtils.waitForSocketNotListening("localhost", 1234, 1000);
}
@AfterGroups
public void afterGroups1() throws IOException {
addImgAttachment();
addStringAttachment();
}
@AfterGroups
public void afterGroups2() throws IOException {
addImgAttachment();
addStringAttachment();
}
@AfterGroups(alwaysRun = true)
final public void afterGroup(ITestContext testContext) {
tearDownPrrallelThreads(testContext, "groups");
}
@AfterGroups("SystemTimeTests")
public void resetSystemCurrentTime() {
DateTimeUtils.setCurrentMillisSystem();
}
@AfterGroups(groups = {"group1"})
public void configAfterGroups(XmlTest test) {
if (test.getName().equals("AfterGroups")) {
throw new RuntimeException();
}
}
@AfterGroups("database")
public void cleanDB() {
System.out.println("cleanDB()");
}
@AfterGroups("positive_tests,regression,negative_tests")
public void runAfterEachGroup() {
numbers.clear();
}