This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

Skip to end of metadata
Go to start of metadata

One of the GSoc 2011 task : OFBIZ-4211 - Getting issue details... STATUS

Related Issue: OFBIZ-4189 - Getting issue details... STATUS

Why selenium 2 ?

Selenium 2.0 is including htmlUnit, which makes it easy to run on an headless server. The driver used (htmlUnit, firefox, …) can be changed, and then drive a real browser.

expected

Functional testing is missing in Apache OFBiz. We already have a lot of unit and services testing, but nothing in a functional way.
Adding webDriver to the project, and making it easy to use will help ensuring a better project consistency, as well as a bigger functionality coverage.
A further development will be the use of the simple method DSL for the functional testing, like the one already existing. This part won’t be covered by this year’s GSoC.

How to ?

the goal is to have an ant task dedicated to this job. In a first iteration, we’ll only concentrate our efforts on making it run with HtmlUnit. Then, we’ll add some options, so the driver can be chosen.
The code will be written in framework/testtools

Architecture

The architecture will be copied on the existing run-tests task.
Tests will be listed in each component in the ofbiz-component.xml file. A new type will be created for those : func-test-suite

   <func-test-suite loader="main" location="testdef/NameOfTestSuite.xml"/>

In the NameOfTestSuite.xm file, the syntax will remain the same:

 
   <test-case case-name="accounting-tests">
       <junit-test-suite class-name="org.ofbiz.accounting.test.FinAccountTests"/>
   </test-case>

The java class will only contain the test, all the preparation will be handled by the framework.

What will be used:

A simple example: login to party application

import org.openqa.selenium.By;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import junit.framework.TestCase;


public class OfbizConnection extends TestCase{
    HtmlUnitDriver driver;

    public void setUp() throws Exception {
        driver = new HtmlUnitDriver();
    }

    public void tearDown() throws Exception {
        driver.quit();
    }

    public void testConnection() throws Exception {
        driver.get("https://localhost:8443/partymgr/control/main");
        assertEquals("OFBiz: Party Manager:", driver.getTitle());

        driver.findElement(By.name("USERNAME")).sendKeys("admin");
        driver.findElement(By.name("PASSWORD")).sendKeys("ofbiz");
        driver.findElement(By.name("loginform")).submit();

        assertTrue(driver.getPageSource().contains("THE PRIVILEGED ADMINISTRATOR"));
        assertEquals("OFBiz: Party Manager: Find Party(s)", driver.getTitle());
    }
}