View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

Automated Testing/Test Case Walkthrough

A sample test case, in functional mode:

Expected result: A success message is displayed

The Controller for this test should look like this:

@RunWith(Parameterized.class)
public class SALa_OrderToInvoice extends OpenbravoERPTest {

 /** The sales order header data. */
 SalesOrderHeaderData salesOrderHeaderData;
 /** The sales order lines data. */
 SalesOrderLinesData salesOrderLinesData;

 public SALa_OrderToInvoice(SalesOrderHeaderData salesOrderHeaderData, SalesOrderLinesData salesOrderLinesData) {
   this.salesOrderHeaderData = salesOrderHeaderData;
   this.salesOrderLinesData = salesOrderLinesData;
}
 @Parameters
 public static Collection<Object[]> salesOrderValues() {
   Object[][] data = new Object[][] { {
       /* Parameters for [SALa010] Create Sales Order. */
       new SalesOrderHeaderData.Builder().transactionDocument("Standard Order").businessPartner(
           new BusinessPartnerSelectorData.Builder().name("Customer A").build()).build(),
       new SalesOrderLinesData.Builder().product(
           new ProductSelectorData.Builder().searchKey("FGA").build()).orderedQuantity("11.2")
           .build()
} };

@Test
 public void goodsReceiptAndSalesInvoiceShouldBeCreatedFromOrder() throws ParseException {
   logger.info("** Start of test case [SALa010] Create Sales Order. **");
   SalesOrder salesOrder = new SalesOrder(mainPage).open();
   salesOrder.create(salesOrderHeaderData);
   salesOrder.assertSaved();
   SalesOrder.Lines salesOrderLines = salesOrder.new Lines(mainPage);
   salesOrderLines.create(salesOrderLinesData);
   salesOrderLines.assertSaved();
   salesOrder.book();
   salesOrder.assertProcessCompletedSuccessfully2();
   logger.info("** End of test case [SALa010] Create Sales Order. **");
}

Lets analyse the code step by step:


@RunWith(Parameterized.class)
public class SALa_OrderToInvoice extends OpenbravoERPTest {

Extension from OpenbravoERPTest class is what allows the test to log in using the configured user and password.

 /** The sales order header data. */
 SalesOrderHeaderData salesOrderHeaderData;
 /** The sales order lines data. */
 SalesOrderLinesData salesOrderLinesData;

Since we are using sales order header and lines, we define two data objects, one for each tab.

 public SALa_OrderToInvoice(SalesOrderHeaderData salesOrderHeaderData, SalesOrderLinesData salesOrderLinesData) {
   this.salesOrderHeaderData = salesOrderHeaderData;
   this.salesOrderLinesData = salesOrderLinesData;
}
 @Parameters
 public static Collection<Object[]> salesOrderValues() {
   Object[][] data = new Object[][] { {
       /* Parameters for [SALa010] Create Sales Order. */
       new SalesOrderHeaderData.Builder().transactionDocument("Standard Order").businessPartner(
           new BusinessPartnerSelectorData.Builder().name("Customer A").build()).build(),
       new SalesOrderLinesData.Builder().product(
           new ProductSelectorData.Builder().searchKey("FGA").build()).orderedQuantity("11.2")
           .build()
} };

Data objects, like Sales Order Header Data Class are standardized classes for parameter management along the Automation objects.

Once created, they can be used following the Builder pattern to add the required data for each test.

@Test
 public void goodsReceiptAndSalesInvoiceShouldBeCreatedFromOrder() throws ParseException {
   logger.info("** Start of test case [SALa010] Create Sales Order. **");
   SalesOrder salesOrder = new SalesOrder(mainPage).open();
   salesOrder.create(salesOrderHeaderData);
   salesOrder.assertSaved();
   SalesOrder.Lines salesOrderLines = salesOrder.new Lines(mainPage);
   salesOrderLines.create(salesOrderLinesData);
   salesOrderLines.assertSaved();
   salesOrder.book();
   salesOrder.assertProcessCompletedSuccessfully2();
   logger.info("** End of test case [SALa010] Create Sales Order. **");

The Test section is the closer to the functional layer. There, the actions required are performed. The data is grabbed from the Data objects and the actions are based on the Screen Definitions. In this example, in the Sales Order definition. This class is a wrapper for the individual tabs composing the Sales Order Window, like Header Tab and Lines Tab. Most of the common behaviour is inherited from a base class, Generated Tab that provides access to the most common actions.


Header and Lines tabs should only implement (and, sometimes, override) the behaviour not defined in Generated Tab class.

Retrieved from "http://wiki.openbravo.com/wiki/Automated_Testing/Test_Case_Walkthrough"

This page has been accessed 2,288 times. This page was last modified on 23 October 2012, at 11:03. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.