Skip to content

Instantly share code, notes, and snippets.

Avatar
☠️
Threading ain't hard… Locking is!

Krishnan Mahadevan krmahadevan

☠️
Threading ain't hard… Locking is!
View GitHub Profile
@krmahadevan
krmahadevan / SampleReporter.java
Created Dec 27, 2019
A reporter example that shows how to extract logs for each Test Method in TestNG
View SampleReporter.java
import java.util.ArrayList;
import java.util.List;
import org.testng.IReporter;
import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.xml.XmlSuite;
public class SampleReporter implements IReporter {
View CreateUser.java
package com.rationaleemotions.stackoverflow.qn55692848;
import org.testng.annotations.Test;
public class CreateUser {
@Test(priority = 1)
public void one() {}
@Test(priority = 2)
View SorterSample.java
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
View Base.java
package com.rationaleemotions.stackoverflow.qn48792353;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
public class Base {
@BeforeSuite
public void beforeSuite() {
System.err.println("beforeSuite() invoked");
}
View SampleTest.java
package com.rationaleemotions;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class SampleTest {
View AbstractTest.java
package com.rationaleemotions.stackoverflow.qn45484794;
import org.testng.annotations.AfterMethod;
import java.util.LinkedList;
import java.util.List;
public abstract class AbstractTest {
public static List<String> messages = new LinkedList<>();
View SampleClassOne.java
package com.rationaleemotions.stackoverflow.qn44518748;
import org.testng.Reporter;
import org.testng.annotations.Test;
public class SampleClassOne {
@Test
public void testMethodA() {
Reporter.log("Executing : " + output(), true);
}
View Console.log
1
Retrying test test with status FAILURE for the 1 time(s).
Test ignored.
java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
@krmahadevan
krmahadevan / ConsoleLogs.txt
Created Mar 11, 2017
The Node configuration file that I used.
View ConsoleLogs.txt
java -jar selenium-server-standalone-3.3.0.jar -role node -hub http://localhost:4444/grid/register -nodeConfig NodeConfig.json -debug true
08:57:28.622 INFO - Selenium build info: version: '3.3.0', revision: 'b526bd5'
08:57:28.623 INFO - Launching a Selenium Grid node
08:57:30.432 DEBUG - CookieSpec selected: default
08:57:30.443 DEBUG - Auth cache not set in the context
08:57:30.444 DEBUG - Connection request: [route: {}->http://localhost:4444][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
08:57:30.549 DEBUG - Connection leased: [id: 0][route: {}->http://localhost:4444][total kept alive: 0; route allocated: 1 of 2000; total allocated: 1 of 2000]
08:57:30.550 DEBUG - Opening connection {}->http://localhost:4444
08:57:30.601 DEBUG - Connecting to localhost/127.0.0.1:4444
08:57:30.613 DEBUG - Connect to localhost/127.0.0.1:4444 timed out. Connection will be retried using another IP address
View ChildClassOne.java
package com.rationaleemotions.stackoverflow;
import org.testng.annotations.Test;
public class ChildClassOne extends MyBaseClass {
public ChildClassOne() {
super(false);
}
@Test
You can’t perform that action at this time.