Showing posts with label TestNG. Show all posts
Showing posts with label TestNG. Show all posts

Monday, 17 November 2014

What is TestNG?

What is TestNG?

Definition of TestNG as per its documentation is:
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.
TestNG is an open source automated testing framework; where NG of TestNGmeans Next Generation. TestNG is similar to JUnit (especially JUnit 4), but its not a JUnit extension. Its inspired by JUnit. It is designed to be better than JUnit, especially when testing integrated classes. The creator of TestNG is Cedric Beust.
TestNG eliminates most of the limitations of the older framework and gives the developer the ability to write more flexible and powerful tests. As it heavily borrows from Java Annotations (introduced with JDK 5.0) to define tests, it can also show you how to use this new feature of the Java language in a real production environment.

Monday, 3 November 2014

How to create a test using TestNG

How to create a test using TestNG





package com.snapdeal;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class GogleTest {
    WebDriver driver = new FirefoxDriver();

    @Test
    public void func() {
        driver.findElement(By.name("q")).sendKeys("test");

    }

    @BeforeTest
    public void beforeTest() {

        driver.get("https://www.google.co.in/?gfe_rd=cr&ei=CoBWVMj9A9jBuATG6ICQDw");
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    }

    @AfterTest
    public void afterTest() {
        driver.close();
    }

}