Thursday, 11 July 2013

PageFactory in Webdriver

In this article i will try to show you how to user PageFactory of webdriver.

Thursday, 4 July 2013

Difference between testng and junit

Testng is unit testing framework inspired junit and nunit .

Following are few points which makes testng more powerful than junit

 

 1. Testng supports parametrized testing , as junit also supports however that is not more effective as testng.
 2. No need to extend any class while coding.
 3. Method dependency can be achieved.
 4.Grouping of test methods can be done. Ex. You can group different set of test methods of  similar functionality.
 5. You can do parallel execution of groups in selenium/wedriver. There is a provision to run all or some of the groups


Testng is more advance  in parametrize testing,dependency testing and suite testing.

Input configuration to testng can be provide by two ways :

1. xml file : You can specify the parameters, class/groups/test in xml file.
2. By Code: Following is the my post link which shows testng coding and report generation.

http://gurushantjidagi.blogspot.in/2013/07/setup-and-trigger-test-automation-using.html


Monday, 1 July 2013

Setup and Trigger test automation using testng through code

This post shows how we could use testng class,generating html report ,setting test classes through the code.

Please download following jars :
1. http://reportng.uncommons.org/ 
2. http://testng.org/doc/download.html

Following is the Java Code:

 public static void main()
{
    Testng tng=new TestNg();
    LinkedList<Class> ll=new LinkedList<Class>();
    ll.add(HTMLReporter.class);

   tng.setTestListenerClasses(ll);
   tng.setOutputDirectory("d:\\test");
   tng.setTestClasses(new Class[]{Test.class});
   tng.run();
}

Following is the sample test class :

class Test
{
 
  @Test
   public void fun() // this methods will pass
  {
    System.out.println("fun");
    Reporter.log("This is passed");  
  }

  @Test
   public void fun2() //this method will fail.
  {
    System.out.println("fun2");
    Reporter.log("This is failed");  
    throw new Error();

  }


  
}