--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
To the best of my knowledge, TestNG doesn’t let you define dependencies amongst suites in the way you describe.
Re-iterating what I said before:
Dependencies can exist only within a <test> tag (because that’s the small level of grouping in TestNG)
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
The issue was within your listener. You shouldn’t be throwing an exception on your onStart(ITestContext) method. You should instead be doing that from within onStart(ITestResult).
Here’s how your fixed listener looks like:
package sample;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import org.testng.SkipException;
public class TestListener implements ITestListener {
private static final String ANSI_GREEN = "\u001B[32m";
private static final String ANSI_YELLOW = "\u001B[33m";
private static final String ANSI_RED = "\u001B[31m";
private static final String ANSI_RESET = "\u001B[0m";
@Override
public void onTestStart(ITestResult result) {
Object value = result.getTestContext().getSuite().getAttribute("skipFurther");
boolean projectSetupFailed = value != null;
if (projectSetupFailed) {
throw new SkipException("Simulating a failure");
}
}
@Override
public void onTestSuccess(ITestResult result) {
getTestLog(result, "PASS", ANSI_GREEN);
}
@Override
public void onTestFailure(ITestResult result) {
getTestLog(result, "FAIL", ANSI_RED);
if (result.getTestContext().getName().equalsIgnoreCase(
"Test1")) {
result.getTestContext().getSuite().setAttribute("skipFurther", true);
}
}
@Override
public void onTestSkipped(ITestResult result) {
getTestLog(result, "SKIP", ANSI_YELLOW);
}
@Override
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
}
@Override
public void onStart(ITestContext context) {
}
@Override
public void onFinish(ITestContext context) {
}
private void getTestLog(ITestResult result, String testStatus, String statusColor) {
float timetakenToExecute = (result.getEndMillis() - result
.getStartMillis()) / 1000.0f;
StringBuilder log = new StringBuilder();
String methodname = result.getTestClass().getName() + "." + result
.getMethod().getMethodName();
String status = statusColor + testStatus + ANSI_RESET;
log.append(methodname);
// Add 1st parameter name in case of data providers
if (result.getParameters().length > 1) {
for (Object eachObject : result.getParameters()) {
String parameter = eachObject.toString();
String[] parameterName = parameter.split("_");
log.append(".").append(parameterName[0]);
}
}
log.append(" ... ");
log.append(status);
log.append(" ");
log.append("(").append(timetakenToExecute).append("s)");
System.out.println(log);
}
}
Output:
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ ipdashboardtests ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
...
... TestNG 7.0.0-beta3 by Cédric Beust (ced...@beust.com)
...
Class1 method
sample.Class1.method1 ... PASS (0.01s)
Class2 method
sample.Class2.method2 ... FAIL (0.0s)
sample.Class3.method3 ... SKIP (0.0s)
[ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 0.466 s <<< FAILURE! - in TestSuite
[ERROR] method2(sample.Class2) Time elapsed: 0.007 s <<< FAILURE!
java.lang.AssertionError: null
at sample.Class2.method2(Class2.java:11)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] Class2.method2:11 null
[INFO]
[ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.979 s
[INFO] Finished at: 2019-03-01T16:03:07+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project ipdashboardtests: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/krmahadevan/temp/mavenproject/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.com/
Hi Krishnana,
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name ="Suite Runner File" verbose="4" >
<listeners>
<listener class-name ="it.jira.seleniumtests.suiteutils.SuiteFailListener" />
</listeners>
<test name ="Project Setup" verbose ="2" >
<classes>
<class name ="it.jira.seleniumtests.smoketests.EasySsoEnableTest"/>
<class name ="it.org.techtime.jira.easysso.seleniumtests.smoketests.LicenseVerificationTest"/>
<!-- <class name ="it.jira.seleniumtests.smoketests.AddOnsPanelTests"/>-->
</classes>
</test>
<test name ="Reporting" verbose ="2" >
<class name ="it.jira.seleniumtests.linksvalidation.AdminScreenTests"/>
</classes>
</test>
</suite>
Gagan,
What is your point that you are trying to make? Can you please elaborate?
If you are saying that my solution didn’t work, that’s perfectly fine. But beyond that, I would like to understand what is it that you are stating?
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.com/
From: <testng...@googlegroups.com> on behalf of Gagandeep Singh <singh.d...@gmail.com>
Reply-To: <testng...@googlegroups.com>
Date: Friday, July 26, 2019 at 1:57 AM
To: testng-users <testng...@googlegroups.com>
Subject: Re: [testng-users] Can we set dependency between <test> tag in testng.xml
Hi Krishnana,
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/65a1d1bd-c419-452b-8dce-ab3c7a3d60e7%40googlegroups.com.