TestNG

  • 02
    Apr

    Custom annotations in TestNG Scripts

    In most Testing frameworks, TestNG Annotations are sufficient enoughh to meet user’s needs, but what if you need a specific runtime behavior for your tests. The solution is your...

    Read More
  • 02
    Apr

    Custom annotations in Java

    Brief: Annotations are meta-meta-objects which can be used to describe other meta-objects e.g. package, class, constructor, variables etc. The process of obtaining meta-object of an object (e.g. anObj.getClass() )...

    Read More
  • 02
    Apr

    Capture screenshot with IHookable implementation

    Step 1: Implement IHookable interface to capture screenshot: ———————————————————— import java.awt.AWTException; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.testng.IHookCallBack; import org.testng.IHookable;...

    Read More
  • 31
    Mar

    Understand failurePolicy in TestNG

    If a TestNG method fails, subsequent methods are skipped. eg. import org.testng.Reporter; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.lang.reflect.Method; public class SampleTestClassWithMultipleMethods { @BeforeMethod public void beforeSampleTestClassWithMultipleMethods(Method method) { if...

    Read More
  • 31
    Mar

    Execute failed test cases using TestNG in Selenium – By using “testng-failed.xml”

    Steps to follow: —————– if some of your TestNG scripts fail, we can adopt following steps to re-execute only failed tests. 1. Open the “”test-output” folder and look for...

    Read More
  • 31
    Mar

    Setting parent testng.xml for your TestNG suite

    Step 1: Create a Parent TestNG.xml ————————————- Step 2: Create your own TestNG2.xml and refer to Parent (TestNG.xml”) as follow: ——————————————————————————– Output: —— First all your test as identified...

    Read More
  • 31
    Mar

    Code for emailable TestNG report

    import org.testng.IReporter; import org.testng.IResultMap; import org.testng.ISuite; import org.testng.ISuiteResult; import org.testng.ITestClass; import org.testng.ITestContext; import org.testng.ITestNGMethod; import org.testng.ITestResult; import org.testng.Reporter; import org.testng.internal.Utils; import org.testng.log4testng.Logger; import org.testng.reporters.util.StackTraceTools; import org.testng.xml.XmlSuite; import java.io.BufferedWriter; import...

    Read More
  • 29
    Mar

    create JIRA issue from Java

    Maven Dependencies: ———————- xml-apis xml-apis 2.0.2 javax.xml jaxp-api 1.4 com.sun.jersey jersey-client 1.8 org.glassfish.jersey.core jersey-client 2.22.1 org.json json 20151123 Souce To create JIRA ticket from Java code: ——————————————- import java.io.IOException;...

    Read More
  • 29
    Mar

    Updating TestNG method results at run-time

    Mark a “SKIP” test as failed in TestNG Mark a “Failed” test as pass in TestNG If we run a scenario with failed tests the “dependsOnMethods” function will be...

    Read More
  • 29
    Mar

    how to capture MANIFEST.MF contents for TestNG

    MANIFEST.MF? from command unzip -c testng-6.9.10.jar META-INF/MANIFEST.MF

    Read More