Best Testng code snippet using org.testng.Interface ITestResult.getName
Source:AbstractChainedListener.java  
...60    61    Set<String> interceptor = Collections.synchronizedSet(new HashSet<String>());62    @Override63    public void onConfigurationSuccess(ITestResult itr) {64        configSuccess.add(itr.getName());65    }66    @Override67    public void onConfigurationFailure(ITestResult itr) {68        configFailure.add(itr.getName());69    }70    @Override71    public void onConfigurationSkip(ITestResult itr) {72        configSkipped.add(itr.getName());73    }74    // @Override omitted to avoid interface conflict75    public void beforeConfiguration(ITestResult tr) {76        beforeConfig.add(tr.getName());77    }78    79    @Override80    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {81        if (method.getTestMethod().isBeforeMethodConfiguration()) {82            beforeMethodBefore.add(testResult.getName());83        } else if (method.isTestMethod()) {84            testMethodBefore.add(testResult.getName());85        } else if (method.getTestMethod().isAfterMethodConfiguration()) {86            afterMethodBefore.add(testResult.getName());87        }88    }89    @Override90    public void afterInvocation(IInvokedMethod method, ITestResult testResult) {91        if (method.getTestMethod().isBeforeMethodConfiguration()) {92            beforeMethodAfter.add(testResult.getName());93        } else if (method.isTestMethod()) {94            testMethodAfter.add(testResult.getName());95        } else if (method.getTestMethod().isAfterMethodConfiguration()) {96            afterMethodAfter.add(testResult.getName());97        }98    }99    @Override100    public void onBeforeClass(ITestClass testClass) {101        beforeClass.add(testClass.getRealClass().getSimpleName());102    }103    @Override104    public void onAfterClass(ITestClass testClass) {105        afterClass.add(testClass.getRealClass().getSimpleName());106    }107    @Override108    public void onTestStart(ITestResult result) {109        testStarted.add(result.getName());110    }111    @Override112    public void onTestSuccess(ITestResult result) {113        testSuccess.add(result.getName());114    }115    @Override116    public void onTestFailure(ITestResult result) {117        testFailure.add(result.getName());118    }119    @Override120    public void onTestSkipped(ITestResult result) {121        testSkipped.add(result.getName());122    }123    @Override124    public void onTestFailedButWithinSuccessPercentage(ITestResult result) {125        testCurved.add(result.getName());126    }127    @Override128    public void onStart(ITestContext context) {129        testsBegun.add(context.getName());130    }131    @Override132    public void onFinish(ITestContext context) {133        testsEnded.add(context.getName());134    }135    @Override136    public void onStart(ISuite suite) {137        suiteBegun.add(suite.getName());138    }139    @Override140    public void onFinish(ISuite suite) {141        suiteEnded.add(suite.getName());142    }143    @SuppressWarnings("rawtypes")144    @Override145    public void transform(ITestAnnotation annotation, Class testClass, Constructor testCtor,146                    Method testMethod) {147        148        if (testClass != null) {149            xformTest.add("class: " + testClass.getSimpleName());150        } else if (testCtor != null) {151            xformTest.add("ctor: " + testCtor.getName());152        } else {153            xformTest.add("method: " + testMethod.getName());154        }155    }156    @SuppressWarnings("rawtypes")157    // @Override omitted to avoid interface conflict158    public void transform(IConfigurationAnnotation annotation, Class testClass,159                    Constructor testCtor, Method testMethod) {160        161        if (testClass != null) {162            xformConfig.add("class: " + testClass.getSimpleName());163        } else if (testCtor != null) {164            xformConfig.add("ctor: " + testCtor.getName());165        } else {166            xformConfig.add("method: " + testMethod.getName());167        }168    }169    // @Override omitted to avoid interface conflict170    public void transform(IDataProviderAnnotation annotation, Method method) {171        xformProvider.add("method: " + method.getName());172    }173    // @Override omitted to avoid interface conflict174    public void transform(IFactoryAnnotation annotation, Method method) {175        if (method != null) {176            xformFactory.add("method: " + method.getName());177        } else {178            xformFactory.add("ctor: (unknown)");179        }180    }181    @SuppressWarnings("rawtypes")182    // @Override omitted to avoid interface conflict183    public void transform(IListenersAnnotation annotation, Class testClass) {184        xformListeners.add("class: " + testClass.getSimpleName());185    }186    187    @Override188    public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {189        interceptor.add(context.getName());190        return methods;191    }192}...Source:TestListener.java  
...42	 * @param iTestResult the i test result43	 * @return the test method name44	 */45	private static String getTestMethodName(ITestResult iTestResult) {46		return iTestResult.getMethod().getConstructorOrMethod().getName();47	}48	/* (non-Javadoc)49	 * @see org.testng.ITestListener#onTestStart(org.testng.ITestResult)50	 */51	@Override52	public void onTestStart(ITestResult result) {53		log.debug("Entering TestListener.onTestStart method " + getTestMethodName(result) + " start");54		Test test = (Test) result.getParameters()[0];55		ExtentTestManager.startTest(test.getName(), "Test Start");56	}57	/* (non-Javadoc)58	 * @see org.testng.ITestListener#onTestSuccess(org.testng.ITestResult)59	 */60	@Override61	public void onTestSuccess(ITestResult result) {62		log.debug("Entering TestListener.onTestSuccess method " + getTestMethodName(result) + " succeed");63		// Extentreports log operation for passed tests.64		// ExtentTestManager.getTest().log(LogStatus.PASS, "Test passed");65	}66	/* (non-Javadoc)67	 * @see org.testng.ITestListener#onTestFailure(org.testng.ITestResult)68	 */69	@Override70	public void onTestFailure(ITestResult iTestResult) {71		// To add it in the extent report72		// logger.log(LogStatus.FAIL, logger.addScreenCapture(screenshotPath));73		/*74		 * log.debug("Entering TestListener.onTestFailure method " +75		 * getTestMethodName(iTestResult) + " failed");76		 * 77		 * // Get driver from BaseTest and assign to local webdriver variable. Object78		 * testClass = iTestResult.getInstance(); WebDriver webDriver = ((WebTest)79		 * testClass).getDriver();80		 * 81		 * // Take base64Screenshot screenshot. String base64Screenshot =82		 * "data:image/png;base64," + ((TakesScreenshot)83		 * webDriver).getScreenshotAs(OutputType.BASE64);84		 * 85		 * // Extentreports log and screenshot operations for failed tests.86		 * ExtentTestManager.getTest().log(LogStatus.FAIL, "Test Failed",87		 * ExtentTestManager.getTest().addBase64ScreenShot(base64Screenshot));88		 */89	}90	/* (non-Javadoc)91	 * @see org.testng.ITestListener#onTestSkipped(org.testng.ITestResult)92	 */93	@Override94	public void onTestSkipped(ITestResult iTestResult) {95		log.debug("Entering TestListener.onTestSkipped method " + getTestMethodName(iTestResult) + " skipped!");96		// Extentreports log operation for skipped tests.97		// ExtentTestManager.getTest().log(LogStatus.SKIP, "Test Skipped");98		log.error("skip exception:: "+iTestResult.getThrowable());99		iTestResult.getThrowable().printStackTrace();100	}101	/* (non-Javadoc)102	 * @see org.testng.ITestListener#onTestFailedButWithinSuccessPercentage(org.testng.ITestResult)103	 */104	@Override105	public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) {106		log.debug("Test failed but it is in defined success ratio " + getTestMethodName(iTestResult));107	}108	/* (non-Javadoc)109	 * @see org.testng.ITestListener#onStart(org.testng.ITestContext)110	 */111	@Override112	public void onStart(ITestContext context) {113		log.debug("Entering TestListener.onStart method " + context.getName());114//		context.setAttribute("WebDriver", this.getDriver());115		116	}117	/* (non-Javadoc)118	 * @see org.testng.ITestListener#onFinish(org.testng.ITestContext)119	 */120	@Override121	public void onFinish(ITestContext context) {122		log.debug("Entering TestListener.onFinish method " + context.getName());123		ExtentTestManager.endTest();124		ExtentTestManager.getReporter().flush();125	}126}...Source:Listener.java  
...30	 * customize the Testing reports.31	 */32	// This belongs to ISuiteListener and will execute before the Suite start33	public void onStart(ISuite isuitestart) {34		Reporter.log("About to begin executing Suite " + isuitestart.getName(), true);35	}36	// This belongs to ISuiteListener and will execute, once the Suite is finished37	public void onFinish(ISuite isuiteend) {38		Reporter.log("About to end executing Suite " + isuiteend.getName(), true);39	}40	// This belongs to ITestListener and will execute before starting of Test41	// set/batch42	public void onStart(ITestContext iteststart) {43		Reporter.log("About to begin executing Test " + iteststart.getName(), true);44	}45	// This belongs to ITestListener and will execute, once the Test set/batch is46	// finished47	public void onFinish(ITestContext itestend) {48		Reporter.log("Completed executing test " + itestend.getName(), true);49	}50	// This belongs to ITestListener and will execute only when the test is pass51	public void onTestSuccess(ITestResult itestpass) {52		// This is calling the printTestResults method53		printTestResults(itestpass);54	}55	// This belongs to ITestListener and will execute only on the event of fail test56	public void onTestFailure(ITestResult itestfail) {57		// This is calling the printTestResults method58		printTestResults(itestfail);59	}60	// This belongs to ITestListener and will execute before the main test start61	// (@Test)62	public void onTestStart(ITestResult mainiteststart) {63		System.out.println("The execution of the main test starts now");64	}65	// This belongs to ITestListener and will execute only if any of the main66	// test(@Test) get skipped67	public void onTestSkipped(ITestResult mainitestskiped) {68		printTestResults(mainitestskiped);69	}70	// This is just a piece of shit, ignore this71	public void onTestFailedButWithinSuccessPercentage(ITestResult successpercentage) {72		73		System.out.println(successpercentage);74	}75	// This is the method which will be executed in case of test pass or fail76	// This will provide the information on the test77	private void printTestResults(ITestResult result) {78		Reporter.log("Test Method resides in " + result.getTestClass().getName(), true);79		if (result.getParameters().length != 0) {80			String params = null;81			for (Object parameter : result.getParameters()) {82				params += parameter.toString() + ",";83			}84			Reporter.log("Test Method had the following parameters : " + params, true);85		}86		String status = null;87		switch (result.getStatus()) {88		case ITestResult.SUCCESS:89			status = "Pass";90			break;91		case ITestResult.FAILURE:92			status = "Failed";...Source:MobileScreenShotListener.java  
...58     * @see org.testng.ITestListener#onStart(org.testng.ITestContext)59     */60    @Override61    public void onStart(final ITestContext ctx) {62        setSuiteName(ctx.getSuite().getName());63    }64    /**65     * On test failed but within success percentage.66     * @param result the result67     * @see org.testng.ITestListener#onTestFailedButWithinSuccessPercentage(org.testng.ITestResult)68     */69    @Override70    public void onTestFailedButWithinSuccessPercentage(final ITestResult result) {71        // Empty implementation.72    }73    /**74     * On test failure.75     * @param result the result76     * @see org.testng.ITestListener#onTestFailure(org.testng.ITestResult)77     */78    @Override79    public void onTestFailure(final ITestResult result) {80        LogUtil.setLogString("\033[41;1mFailed  " + System.getProperty(DriverConfig.ENV)81                + ", " + result.getName(), true);82        WaitUtil.mediumWait();83        try {84            operations.takeScreenShot(result.getMethod().getTestClass().getName()85                    .substring(result.getMethod().getTestClass().getName().lastIndexOf('.') + 1)86                    + "." + result.getName());87        } catch (final DeviceException e) {88            e.printStackTrace();89        }90    }91    /**92     * On test skipped.93     * @param iTestResult the i test result94     * @see org.testng.ITestListener#onTestSkipped(org.testng.ITestResult)95     */96    @Override97    public void onTestSkipped(final ITestResult iTestResult) {98        LogUtil.setLogString("\033[44;1mSkipped " + System.getProperty(DriverConfig.ENV) + " "99                + iTestResult.getName(), true);100    }101    /**102     * On test start.103     * @param iTestResult the i test result104     * @see org.testng.ITestListener#onTestStart(org.testng.ITestResult)105     */106    @Override107    public void onTestStart(final ITestResult iTestResult) {108        resetTestCaseData();109        setTestName(iTestResult.getMethod().getMethodName());110    }111    /**112     * On test success.113     * @param iTestResult the i test result114     * @see org.testng.ITestListener#onTestSuccess(org.testng.ITestResult)115     */116    @Override117    public void onTestSuccess(final ITestResult iTestResult) {118        String testClass = iTestResult.getTestClass().getName();119        testClass = testClass.substring(testClass.lastIndexOf('.') + 1, testClass.length());120        PageUtil.deleteScreenshot(testClass + "." + iTestResult.getMethod(),121                operations.getDeviceDriver());122        LogUtil.setLogString("\033[42;1mPassed " + System.getProperty(DriverConfig.ENV) + " "123                + iTestResult.getName(), true);124    }125}...Source:Github1649Test.java  
...19public class Github1649Test extends SimpleBaseTest {20  @Test21  public void testHappyFlowForNativeInjectionOnTestMethods() {22    Map<String, List<String>> mapping = Maps.newHashMap();23    mapping.put("m1", Collections.singletonList(Method.class.getName()));24    mapping.put("m2", Collections.singletonList(ITestContext.class.getName()));25    mapping.put("m3", Collections.singletonList(XmlTest.class.getName()));26    mapping.put("m4", Arrays.asList(ITestContext.class.getName(), XmlTest.class.getName()));27    mapping.put("m5", Arrays.asList(XmlTest.class.getName(), ITestContext.class.getName()));28    mapping.put("m6", Arrays.asList(Method.class.getName(), ITestContext.class.getName()));29    mapping.put("m7", Arrays.asList(ITestContext.class.getName(), Method.class.getName()));30    mapping.put("m8", Arrays.asList(Method.class.getName(), XmlTest.class.getName()));31    mapping.put("m9", Arrays.asList(XmlTest.class.getName(), Method.class.getName()));32    mapping.put(33        "m10",34        Arrays.asList(35            Method.class.getName(), XmlTest.class.getName(), ITestContext.class.getName()));36    mapping.put(37        "m11",38        Arrays.asList(39            Method.class.getName(), ITestContext.class.getName(), XmlTest.class.getName()));40    mapping.put(41        "m12",42        Arrays.asList(43            XmlTest.class.getName(), Method.class.getName(), ITestContext.class.getName()));44    mapping.put(45        "m13",46        Arrays.asList(47            XmlTest.class.getName(), ITestContext.class.getName(), Method.class.getName()));48    mapping.put(49        "m14",50        Arrays.asList(51            ITestContext.class.getName(), Method.class.getName(), XmlTest.class.getName()));52    mapping.put(53        "m15",54        Arrays.asList(55            ITestContext.class.getName(), XmlTest.class.getName(), Method.class.getName()));56    TestNG testng = create(HappyPathNativeInjectionTestSample.class);57    Github1649TestListener listener = new Github1649TestListener();58    testng.addListener(listener);59    testng.run();60    assertThat(listener.mapping).containsAllEntriesOf(mapping);61  }62  @Test63  public void testNegativeFlowForNativeInjectionOnTestMethods() {64    Map<String, String> failures = Maps.newHashMap();65    failures.put(66        "m1", "Cannot inject @Test annotated Method [m1] with [interface org.testng.ITestResult].");67    failures.put("m2", "Cannot inject @Test annotated Method [m2] with [int].");68    TestNG testng = create(NegativeNativeInjectionTestSample.class);69    Github1649TestListener listener = new Github1649TestListener();70    testng.addListener(listener);71    testng.run();72    assertThat(listener.failures).containsAllEntriesOf(failures);73  }74  public static class Github1649TestListener extends TestListenerAdapter75      implements IInvokedMethodListener {76    Map<String, List<String>> mapping = Maps.newHashMap();77    Map<String, String> failures = Maps.newHashMap();78    @Override79    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {}80    @Override81    public void onTestFailure(ITestResult testResult) {82      String methodName = testResult.getMethod().getMethodName();83      String raw = testResult.getThrowable().getMessage();84      String actual = raw.split("\n")[1];85      failures.put(methodName, actual);86    }87    @Override88    public void afterInvocation(IInvokedMethod method, ITestResult testResult) {89      String methodName = testResult.getMethod().getMethodName();90      List<String> paramTypes = Lists.newArrayList();91      for (Object parameter : testResult.getParameters()) {92        String value = parameter.getClass().getName();93        if (parameter instanceof ITestContext) {94          value = ITestContext.class.getName();95        }96        paramTypes.add(value);97      }98      mapping.put(methodName, paramTypes);99    }100  }101}...Source:ScreenShotListener.java  
...57     */58    @Override59    public void onTestFailure(ITestResult result) {60    	WaitUtil.mediumWait();61        PageUtil.saveScreenshot(result.getMethod().getTestClass().getName()62                .substring(result.getMethod().getTestClass().getName().lastIndexOf('.') + 1)63                + "." + result.getName(), DriverConfig.getDriver());64    }65    /**66     * On test skipped.67     * @param iTestResult the i test result68     * @see org.testng.ITestListener#onTestSkipped(org.testng.ITestResult)69     */70    @Override71    public void onTestSkipped(ITestResult iTestResult) {72        DriverConfig.setLogString("\033[44;1mSkipped " + System.getProperty(DriverConfig.ENV) + " " + System.getProperty(DriverConfig.BROWSER) + " " + iTestResult.getName(), true);73    }74    /**75     * On test start.76     * @param iTestResult the i test result77     * @see org.testng.ITestListener#onTestStart(org.testng.ITestResult)78     */79    @Override80    public void onTestStart(ITestResult iTestResult) {81    }82    /**83     * On test success.84     * @param iTestResult the i test result85     * @see org.testng.ITestListener#onTestSuccess(org.testng.ITestResult)86     */87    @Override88    public void onTestSuccess(ITestResult iTestResult) {89        DriverConfig.setLogString("\033[42;1mPassed " + System.getProperty(DriverConfig.ENV) + " " + System.getProperty(DriverConfig.BROWSER) + " " + iTestResult.getName(), true);90    }91}...Source:TestNGListeners.java  
...11{12	@Override13	public void onTestStart(ITestResult result)				//it has parameter 'ITestResult', so whatever result comes it will be stored in result object 14	{15		System.out.println("Testcase started and details are"+result.getName());													//this listener gives testcase name of the one failed among 15 testcases16		17	}18	@Override19	public void onTestSuccess(ITestResult result) 20	{21		System.out.println("Testcase passed and details are"+result.getName());22		23	}24	@Override25	public void onTestFailure(ITestResult result) 26	{27		System.out.println("Testcase failed and details are"+result.getName());28		29	}30	@Override31	public void onTestSkipped(ITestResult result) 32	{33		34		System.out.println("Testcase skipped and details are"+result.getName());35	}36	@Override37	public void onTestFailedButWithinSuccessPercentage(ITestResult result) {38		39		40	}41	@Override42	public void onStart(ITestContext context) {43		44		45	}46	@Override47	public void onFinish(ITestContext context) {48		...Source:Listener1.java  
...6public class Listener1 implements ITestListener //Listener is used in selenium by implementing Listeners Interface.7{// below overridden methods are methods of interface and here we have provided implementation to all.8	@Override9	public void onTestStart(ITestResult result) {10		System.out.println("*** Test started : "+result.getName());11	}1213	@Override14	public void onTestSuccess(ITestResult result) {15		System.out.println("*** Test Success : "+result.getName());16	}1718	@Override19	public void onTestFailure(ITestResult result) {20		System.out.println("*** Test failed (take screenshot code to add here) : "+result.getName());21	}2223	@Override24	public void onTestSkipped(ITestResult result) {25		System.out.println("*** Test skipped : "+result.getName());26	}2728	@Override29	public void onTestFailedButWithinSuccessPercentage(ITestResult result) {30		System.out.println("*** Test fail success % : "+result.getName());31	}3233	@Override34	public void onTestFailedWithTimeout(ITestResult result) {35		System.out.println("*** Test failed timout : "+result.getName());36	}3738	@Override39	public void onStart(ITestContext context) {40		System.out.println("*** Test On start : "+context.getName());41	}4243	@Override44	public void onFinish(ITestContext context) {45		System.out.println("*** Test On finish : "+context.getName());46	}47}
...getName
Using AI Code Generation
1import org.testng.ITestResult;2import org.testng.TestListenerAdapter;3public class TestListener extends TestListenerAdapter {4    public void onTestSuccess(ITestResult tr) {5        System.out.println("Test " + tr.getName() + " passed");6    }7    public void onTestFailure(ITestResult tr) {8        System.out.println("Test " + tr.getName() + " failed");9    }10    public void onTestSkipped(ITestResult tr) {11        System.out.println("Test " + tr.getName() + " skipped");12    }13}14[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ TestNG ---15[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ TestNG ---16[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ TestNG ---17[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ TestNG ---18[INFO] --- maven-surefire-plugin:3.0.0-M4:test (default-test) @ TestNG ---getName
Using AI Code Generation
1public class TestNGListener implements ITestListener, IInvokedMethodListener {2    public void onTestStart(ITestResult result) {3        System.out.println("Test Started: " + result.getName());4    }5    public void onTestSuccess(ITestResult result) {6        System.out.println("Test Passed: " + result.getName());7    }8    public void onTestFailure(ITestResult result) {9        System.out.println("Test Failed: " + result.getName());10    }11    public void onTestSkipped(ITestResult result) {12        System.out.println("Test Skipped: " + result.getName());13    }14    public void onTestFailedButWithinSuccessPercentage(ITestResult result) {15        System.out.println("Test Failed With Success Percentage: " + result.getName());16    }17    public void onStart(ITestContext context) {18        System.out.println("Test Started: " + context.getName());19    }20    public void onFinish(ITestContext context) {21        System.out.println("Test Finished: " + context.getName());22    }23    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {24        System.out.println("Test Started: " + method.getTestMethod().getMethodName());25    }26    public void afterInvocation(IInvokedMethod method, ITestResult testResult) {27        System.out.println("Test Finished: " + method.getTestMethod().getMethodName());28    }29}getName
Using AI Code Generation
1package com.test;2import java.io.File;3import java.io.FileInputStream;4import java.io.FileNotFoundException;5import java.io.IOException;6import java.util.Iterator;7import java.util.Set;8import org.apache.poi.hssf.usermodel.HSSFCell;9import org.apache.poi.hssf.usermodel.HSSFRow;10import org.apache.poi.hssf.usermodel.HSSFSheet;11import org.apache.poi.hssf.usermodel.HSSFWorkbook;12import org.openqa.selenium.By;13import org.openqa.selenium.WebDriver;14import org.openqa.selenium.WebElement;15import org.openqa.selenium.chrome.ChromeDriver;16import org.openqa.selenium.support.ui.Select;17import org.testng.Assert;18import org.testng.ITestResult;19import org.testng.annotations.AfterMethod;20import org.testng.annotations.AfterTest;21import org.testng.annotations.BeforeClass;22import org.testng.annotations.BeforeTest;23import org.testng.annotations.DataProvider;24import org.testng.annotations.Test;25public class TestNGTest {26    WebDriver driver;27    String driverPath = "C:\\Users\\User\\Desktop\\chromedriver_win32\\chromedriver.exe";28    HSSFWorkbook workbook;29    HSSFSheet sheet;30    HSSFRow row;31    HSSFCell cell;32    String testDataFile = "C:\\Users\\User\\Desktop\\testData.xls";33    String data;34    public void setDriverPath() {35        System.setProperty("webdriver.chrome.driver", driverPath);36    }37    public void launchBrowser() {38        driver = new ChromeDriver();39        driver.manage().window().maximize();40    }41    @DataProvider(name = "testData")42    public Object[][] testData(ITestResult result) throws IOException {43        String testName = result.getMethod().getMethodName();44        System.out.println("Test name is: " + testName);45        FileInputStream fis = new FileInputStream(testDataFile);46        workbook = new HSSFWorkbook(fis);47        sheet = workbook.getSheetAt(0);48        int totalRows = sheet.getLastRowNum();49        System.out.println("Total rows are: " + totalRows);50        int totalCols = sheet.getRow(0).getLastCellNum();51        System.out.println("Total columns are: " + totalCols);52        String[][] data = new String[totalRows][totalCols];53        for (int i = 1TestNG is a Java-based open-source framework for test automation that includes various test types, such as unit testing, functional testing, E2E testing, etc. TestNG is in many ways similar to JUnit and NUnit. But in contrast to its competitors, its extensive features make it a lot more reliable framework. One of the major reasons for its popularity is its ability to structure tests and improve the scripts' readability and maintainability. Another reason can be the important characteristics like the convenience of using multiple annotations, reliance, and priority that make this framework popular among developers and testers for test design. You can refer to the TestNG tutorial to learn why you should choose the TestNG framework.
You can push your abilities to do automated testing using TestNG and advance your career by earning a TestNG certification. Check out our TestNG certification.
Watch this complete tutorial to learn how you can leverage the capabilities of the TestNG framework for Selenium automation testing.
Get 100 minutes of automation test minutes FREE!!
