Unable to see messages when using ITestListner of testNG

Unable to see messages when using ITestListner of testNG

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import org.testng.annotations.Test;
public class DList implements ITestListener {
@Test
public void clear()
{
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.findElement(By.id("email")).sendKeys("mukesh@facebook.com");
driver.findElement(By.id("wronglocator")).sendKeys("dont-tell");
driver.findElement(By.id("loginbutton")).click();
}
public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) {
}
public void onTestFailure(ITestResult arg0) {
System.out.println("test fail"+arg0.toString());
}
public void onTestSkipped(ITestResult arg0) {
System.out.println("test skipped"+arg0.toString());
}
public void onTestStart(ITestResult arg0) {
System.out.println("test started"+arg0.toString());
}
public void onTestSuccess(ITestResult arg0) {
System.out.println("test success"+arg0.toString());
}
public void onFinish(ITestContext arg0) {
System.out.println("test finished"+arg0.toString());
}
public void onStart(ITestContext arg0) {
System.out.println("initialized"+arg0.toString());
}
}

My Testng.xml file look like this………….

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”>
<suite name=”Test-listner” parallel=”none”>
<listners>
<listner class-name=”List.DList”>
</listner>
</listners>
<test name=”Batch-listner”>
<classes>
<class name=”List.DList”/>
</classes>
</test> <!– Test –>
</suite> <!– Suite –>

Hi

This is very unusual way of implementation , havent tried this before but could please take your @Test Method and implement as part of other class and then try ?

on January 2, 2015.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.