Monday, August 6, 2012

Junit test suite for Selenium Webdriver 2.0

Using Junit test suite, we can run the test cases in Selenium Webriver. 

Here is the sample snippet.

// Test class1

public class c1 {
    @Test
    public void one(){
        System.out.println("one");
    }

}

//Test class 2
public class c2 {
    @Test
    public void two(){
        System.out.println("two");
    }

}

//JUnit suite

import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@SuppressWarnings("unused")
@RunWith(Suite.class)
@SuiteClasses({c1.class, c2.class})
public class suite {

}

2 comments:

  1. Hi,

    How to Write Logs in Selenium (Selenium RC and also in WebDriver) and where this has to be maintained in the Framework..

    Thanks in Advance

    ReplyDelete
  2. These steps are same as configuring Junit in eclipse without selenium. Is it possible to configure the same using Maven. I mean Selenium and Junit working in sync using pom.xml.

    ReplyDelete