Monday, 1 September 2014

Testng

        Steps for installation in eclipse:

Step:1 Download the testng archieve
              http://www.testng.org

Step:2  Set Eclipse Environment

Open eclipse -> right click on project and click on property > Build Path > Configure Build Path and add the testng-6.8.jar in the libraries using Add External Jar button.




We assume that your eclipse has inbuilt TestNG plug-in; if it is not available, then please get the latest version using the update site:

In your eclipse IDE, select Help / Software updates / Find and Install.

Search for new features to install.

New remote site.

For Eclipse 3.4 and above, enter http://beust.com/eclipse.

For Eclipse 3.3 and below, enter http://beust.com/eclipse1.

Make sure the check box next to URL is checked and click Next.

Eclipse will then guide you through the process.

Now, your eclipse is ready for the development of TestNG test cases.

Step 3: Verify the Testng installation

Create a project TestNGProject in eclipse at any location.

Create a class shows the messato test in the project.

 
/*
* This class prints the given message on console.
*/
public class MessageUtil {

   private String message;

   //Constructor
   //@param message to be printed
   public MessageUtil(String message){
      this.message = message;
   }
   
   // prints the message
   public String printMessage(){
      System.out.println(message);
      return message;
   }
}
Create a test class TestNGExample in the project.

 
import org.testng.Assert;
import org.testng.annotations.Test;

public class TestNGExample {
    String message = "Hello World";
    MessageUtil messageUtil = new MessageUtil(message);

    @Test
    public void testPrintMessage() {
       Assert.assertEquals(message,messageUtil.printMessage());
   }
}

Project Structure:






Output:








To know FAQ's on Selenium Please ClickHere
To know SQL's Queries Required For Testers Please ClickHere

No comments:

Post a Comment