--
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/b93d4ed1-5370-48d3-b1a4-3195bec34822n%40googlegroups.com.
import org.testng.ITestContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class SampleTestClass {
@BeforeClass(alwaysRun = true)
public void init(ITestContext iTestContext) {
System.err.println("Setting feature for " + iTestContext.getName());
iTestContext.setAttribute("feature", "Login");
}
@Test(description = "Sample Test 1")
public void testSample1() {
}
}
import org.testng.ITestContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class SampleTestClass2 {
@BeforeClass(alwaysRun = true)
public void init(ITestContext iTestContext) {
System.err.println("Setting feature for " + iTestContext.getName());
iTestContext.setAttribute("feature", "Create Page");
}
@Test(description = "Sample Test 2")
public void testSample2() {
}
}
import org.testng.IReporter;
import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.xml.XmlSuite;
import java.util.List;
public class Printer implements IReporter {
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
suites.stream()
.flatMap(it -> it.getResults().values().stream())
.map(ISuiteResult::getTestContext)
.forEach(it -> {
System.err.println("Printing attributes for " + it.getName());
it.getAttributeNames()
.forEach(attribute -> System.err.println(attribute + ": " + it.getAttribute(attribute)));
});
}
}
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="2980_suite" verbose="2" parallel="tests">
<listeners>
<listener class-name="com.rationaleemotions.testnggroups.attributes.Printer"/>
</listeners>
<test name="login_feature" verbose="2">
<classes>
<class name="com.rationaleemotions.testnggroups.attributes.SampleTestClass"/>
</classes>
</test>
<test name="create_page_feature" verbose="2">
<classes>
<class name="com.rationaleemotions.testnggroups.attributes.SampleTestClass2"/>
</classes>
</test>
</suite>
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/d5b8773e-06e8-422e-b8dc-8c7c9ed18fc5n%40googlegroups.com.