Fitnesse Test Case.HowTo

From iDempiere en
(Redirected from Fitnesse.HowToTestCase)

Feature: Fitnesse Test Case.HowTo

Goal: Functional Testing

Sponsor: Trek Global

Description:

To design and write a successful test in fitnesse you must know several concepts.

Suite

A suite is a collection of test pages that can all be run together, and whose results are then collected for you on a single results page.

Suite.png

Setting up a suite page.

To create a suite page you set the "Suite" property of that page. That page will then include a "Suite" button that will execute all the test pages in that hierarchy.

SuiteEdit.png


Composing Suites.


There are several ways to compose a suite. You can convert a whole subwiki into a suite. You can list individual pages using cross references, and you can create queries that search all the pages for matches.

Test

FitNesse automated acceptance tests are power tools for fixing a broken requirements process.


Test Example

  • This test are an example to cash pos order
  • First include the test login (Mandatory) :
!include -c TestLoginGardenAdmin


  • Check the inventory level before the document: Using Fixture Set Variable, @SQL
!|Set Variable|
|@InventoryLevelBefore@       |@SQL=SELECT SUM(s.qtyonhand) FROM m_storage s, m_locator l, m_warehouse w WHERE s.m_product_id=133 AND s.m_locator_id = l.m_locator_id AND l.m_warehouse_id=w.m_warehouse_id AND w.m_warehouse_id=103   |
|@ExpectedInventoryLevelAfter@|@SQL=SELECT SUM(s.qtyonhand) -2 FROM m_storage s, m_locator l, m_warehouse w WHERE s.m_product_id=133 AND s.m_locator_id = l.m_locator_id AND l.m_warehouse_id=w.m_warehouse_id AND w.m_warehouse_id=103|


  • Check the business partner balance before the document: Using Fixture Read Record, @Ref
!|Read Record|
|*Table*            |C_bpartner                                     |
|c_bpartner_id      |@Ref=c_bpartner[Value='SeedFarm'].c_bpartner_id|
|*Read*             |                                               |
|actuallifetimevalue|                                               |
|so_creditused      |                                               |
|totalopenbalance   |                                               |


  • Create sales order: Using fixture Create Record, @Ref, context variable @c_bpartner.c_bpartner_id@
!|Create Record|
|*Table*               |C_Order                                      |
|ad_org_id             |11                                           |
|c_doctypetarget_id    |@Ref=c_doctype[Name='POS Order'].c_doctype_id|
|salesrep_id           |101                                          |
|dateordered           |2009-03-25 00:00:00.0                        |
|c_bpartner_id         |@c_bpartner.c_bpartner_id@                   |
|c_bpartner_location_id|114                                          |
|paymentrule           |B                                            |
|m_warehouse_id        |103                                          |
|m_pricelist_id        |101                                          |
|ad_user_id            |105                                          |
|*Save*                |                                             |
  • Create sales order line related: Using Fixture Create Record, context variable, @Ref
!|Create Record|
|*Table*     |C_OrderLine                                |
|c_order_id  |@C_order.c_Order_id@                       |
|ad_org_id   |@C_Order.AD_Org_ID@                        |
|m_product_id|@Ref=M_Product[Value='PChair'].M_Product_ID|
|qtyentered  |2                                          |
|qtyordered  |2                                          |
|*Save*      |                                           | 
  • Complete the sales order: Using Fixture Run Process, Context variable
!|Run Process|
|*ProcessValue*|C_Order Process     |
|*RecordID*    |@C_Order.C_Order_ID@|
|*DocAction*   |CO                  |
|*Run*         |                    |
  • Assert the order the Grand Total to the expected: Using Fixture Assert Record, context variable
!|Assert Record|
|*Table*   |C_order             |
|c_order_id|@C_order.c_Order_id@|
|*Read*    |                    |
|GrandTotal|67.50               |


  • Check the inventory level after the document with @ExpectedInventoryLevelAfter@ be the expected: Using Fixture Assert Variable, context variable
!|Assert Variable|
|@ExpectedInventoryLevelAfter@|@SQL=SELECT SUM(s.qtyonhand) FROM m_storage s, m_locator l, m_warehouse w WHERE s.m_product_id=133 AND s.m_locator_id = l.m_locator_id AND  l.m_warehouse_id=w.m_warehouse_id AND w.m_warehouse_id=103|


  • Check the Bussines Parnert balance after the document: Using Fixture Assert Record
!|Assert Record|
|*Table*            |C_bpartner                                                                   |
|*Where*            |c_bpartner_id=120                                                            |
|*Read*             |                                                                             |
|actuallifetimevalue|@SQL=SELECT @C_bpartner.actuallifetimevalue@ + @c_order.grandtotal@ FROM DUAL|
|so_creditused      |@SQL=SELECT @C_bpartner.so_creditused@ + @c_order.grandtotal@ FROM DUAL      |
|totalopenbalance   |@SQL=SELECT @C_bpartner.totalopenbalance@ + @c_order.grandtotal@ FROM DUAL   |


  • Check existence of shipment related to the Sales Order: Using Fixture Read Record Context Variable
!|Read Record|
|*Table*       |M_InOut             |
|c_order_id    |@C_Order.C_Order_ID@|
|*Read*        |                    |
|documentno    |                    |
|docstatus     |                    |
|issotrx       |                    |
|m_warehouse_id|                    |
|description   |                    |


  • Check existence of shipment Lines related to the Sales Order Lines: Using Fixture Read Record Context Variable
!|Read Record|
|*Table*       |M_InOutLine         |
|m_inout_id    |@M_InOut.M_InOut_ID@|
|*Read*        |                    |
|line          |                    |
|description   |                    |
|c_orderline_id|                    |
|m_locator_id  |                    |
|m_product_id  |                    |
|movementqty   |                    |


  • Check existence of invoice related to the sales Order: Using Fixture Read Record Context Variable
!|Read Record|
|*Table*      |C_Invoice           |
|c_order_id   |@C_Order.C_Order_ID@|
|*Read*       |                    |
|documentno   |                    |
|issotrx      |                    |
|docstatus    |                    |
|c_bpartner_id|                    |
|description  |                    |
|totallines   |                    |
|grandtotal   |                    |


  • Check existance of invoice Lines related to the sales Order lines: Using Fixture Read Record Context Variable
!|Read Record|
|*Table*       |C_InvoiceLine           |
|C_Invoice_id  |@C_Invoice.C_Invoice_id@|
|*Read*        |                        |
|line          |                        |
|description   |                        |
|c_orderline_id|                        |
|m_product_id  |                        |
|qtyinvoiced   |                        |
|linenetamt    |                        |


  • Check existance of cash journal line related: Using Fixture Read Record Context Variable
!|Read Record|
|*Table*     |C_CashLine              |
|C_Invoice_id|@C_Invoice.C_Invoice_id@|
|*Read*      |                        |
|line        |                        |
|c_cash_id   |                        |
|line        |                        |
|description |                        |
|amount      |                        |
|isgenerated |                        |
|processed   |                        |
Cookies help us deliver our services. By using our services, you agree to our use of cookies.