Fitnesse.FixtureReference

From iDempiere en

Feature: Fitnesse Fixture Reference

Goal: Functional Testing


Sponsor: Trek Global


Description:

FitNesse provides various “Test Table Styles” (or fixtures) to write your tests. Each Table/Fixture Style has its own usage and purpose which allow testers to write acceptance tests without needing development support of writing fixture specific code for each new transaction. Thus this document is going to describe what fixtures can be used and how, but before proceeding to explain how they work, the following concepts are important to understand :


  • Context Variable: The purpose of a context variable is to have a visible value during the whole test execution. There are four types of Context Variable
  • User Defined: @variable_name@
  • Pre-defined by Idempiere: this variables were created to keep several kind of operations such as:

@SQL: Allow to keep a value returned from a SQL statement, please notice that another context variables can be used within the SQL statement.

@Ref: Allow to keep a reference value from a specific table-column, the proper structure to use it is "@Ref = Table[Where]. Column e.g. :

@Ref=AD_Client[Value='GardenWorld'].AD_Client_ID"

@random_number: to generate a random number,it accepts parameters such as: PREFIX, SUFFIX, LENGTH and DECIMALS.

@random_string: to generate a random string,it accepts parameters such as: PREFIX,SUFFIX,LENGTH


  • You can identify an action because of the asterisks (*) depends of the fixture


Notice :

1. If fixtures passes successfully, its rows will be colored GREEN otherwise will be colored RED

2. If the character @ is needed in a sentence, then two backslash must be used e.g. //@

3. !include -c : You can include a test you already do it


Table Structure

  • The wiki page includes some form of decision table which expresses a test.

The structure to write table test:

  • The character exclamation mark  ! must in the first line
  • Fixture Name : name's fixture
  • *Value* : Value related to the fixture
  • Column : Table Column
  • Variable : Variables related to the fixture
  • *Execute* : Action to execute the test depends the fixture (*Read, *save*,*Login*, *Run*)
!|Fixture Name|
 |[*Value* |Context Variable | Name's Table | User ] | (Optional)
 |[Column  | Variable | Password | ] | (Optional)
 |[Column] | (Optional)
 |[*Execute*] | (Optional)
 |[Column] | (Optional)


Set Variable



This fixture allows to set a value

Parameters:

  • @variable@ : Variable to set


Return: The defined value kept in context.


For example:

SetVariable.png


How to write


!|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|



Assert Record



This fixture allows to read a record from database and check out against as expected value

Parameters:

  • *Table* : Name's table
  • Input Columns : Columns related to the table
  • Expected Values : Columns related to the table

Optional parameters

  • *Where* : To define columns in the sentence (must be defined in second row)

Command to execute

  • *Read* : To execute the fixture and read a record
  • *Read*Error* : To execute the fixture and expect to happen a error reading the record, you can use a message error to verify that error want to happen is the same that shows the System

Return:

  • Values expected to assert


For example:

AssertRecord.png

How to write

!|Assert Record|
|*Table*   |C_order             |
|c_order_id|@C_order.c_Order_id@|
|*Read*    |                    |
|GrandTotal|67.50               |


!|Assert Record|
|*Table*     |C_order             |
|c_order_id  |@C_order.c_Order_id@|
|*Read*Error*|No record Found     |
|GrandTotal  |67.50               |



Assert Variable


This fixture assert a variable in otherwise the previous, this can be define previously (Assert Record), could be context variable, or returns from another fixture createRecord, readRecord


Parameters:

  • Variables : variables to set


Return:

  • The value expected

For example:

AssertVariable.png


How to write

!|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|


Create Record



This fixture allows to create a new record in a table which is processed thought Idempiere Model


Parameters:

  • *Table* : Name's table
  • Value (s) : Values of the columns


Command to execute

  • *Save* : To execute the fixture and save a new record
  • *Save*Error* : To execute the fixture and expect to happen a error when save the register


For example:

CreateRecord.png


How to write

!|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 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_location_id|114                                          |
|paymentrule           |B                                            |
|m_warehouse_id        |103                                          |
|m_pricelist_id        |101                                          |
|ad_user_id            |105                                          |
|*Save*Error*          |c_bpartner_id can not be null                |

Login


This fixture allows to test the login action, and must be execute before anything else. Please notice Idempiere security schema applies.

Parameters:

  • User : User name to login
  • Password : Password related to the user
  • AD_Client_ID : Client Id
  • AD_Role_ID : Role Id
  • Language : Language to view


Optional parameters

  • AD_Org_ID : Organization Id
  • M_Warehouse_ID : Warehouse Id


Command to execute

  • *Login* : To execute the fixture and login action
  • *Login*Error* : To execute the fixture and expect to happen a error


Return:

  • Logged successful

For Example:

Login.png


How to write

!|Login|
|User        |SuperUser|
|Password    |System   |
|AD_ClIEnT_id|0        |
|AD_Role_id  |0        |
|*Login*     |         |


!|Login|
|User          |SuperUser|
|Password      |System   |
|AD_ClIEnT_id  |0        |
|AD_Role_id    |100002   |
|*Login*Error* |No role  |

Read Record


This fixture allows to read a record from a table with parameters previously defined

Parameters:

  • *Table* : Name's table
  • Set Columns : Set columns want to read


Optional parameters

  • *Where* : To define columns in the sentence (must be defined in second row)


Command to execute

  • *Read* : To execute the fixture and read a record
  • *Read*Error* : To execute the fixture and expect to happen an error when read the register

Return: The empty fields defined are populate.


For example:

ReadRecord.png


How to write

!|Read Record|
|*Table*            |C_bpartner|
|c_bpartner_id      |120       |
|*Read*             |          |
|actuallifetimevalue|          |
|so_creditused      |          |
|totalopenbalance   |          |


!|Read Record|
|*Table*            |C_bpartner       |
|c_bpartner_id      |1000002          |
|*Read*Error*       |No record found  |
|actuallifetimevalue|                 |
|so_creditused      |                 |
|totalopenbalance   |                 |

Run Process


This fixture allows to run a process but not a report


Parameters:

  • *ProcessValue* : Value's process


Optional Parameters

  • *RecordID* : Record ID related to the process
  • *ProcessID* : Process ID related to the process
  • *DocAction* : Document action to execute
  • Parameters : Column's name related, please filled and if one of them is range the second range must follow by "_2" e.g. "time_2"


Command to execute

  • *Run* : To execute the fixture
  • *Run*Error* : To execute the fixture and expect and error

For example:

RunProcess.png


How to write

!|Run Process|
|*ProcessValue*|C_Order Process     |
|*RecordID*    |@C_Order.C_Order_ID@|
|*DocAction*   |CO                  |
|*Run*         |                    |
!|Run Process|
|*ProcessValue*|C_Order Process     |
|*RecordID*    |@C_Order.C_Order_ID@|
|*DocAction*   |CO                  |
|*Run*Error*   |No Documents Lines  |

Set Doc Action


This fixture allows to implement an action over a related document

Parameters:

  • *Table* : Name's table
  • RecordID : Record ID
  • DocAction : Document action you to be done, the option available are :
            Complete = "CO"
            Approve = "AP"
            Reject = "RJ"
            Post = "PO" (posted a document)
            Void = "VO"
            Reverse Accrual = "RA"
            Invalidate = "IN"
            Re Activate = "RE"
            WaitComplete = "WC"


Command to execute

  • Save : To execute the fixture and save


For example:

SetDocAction.png

How to write

!|Set DocAction        |
|*Table*     |C_Payment|
|C_Payment_ID|100      |
|docAction   |VO       |
|*Save*      |         |


Update Record


This fixture allows to update a register

Parameters:

  • *Table* : Name's table
  • *Where* : Some condition that return just one register
  • Fields to update


Command to execute

  • *Update* : To execute the fixture and update
  • *Update*Error* : To execute the fixture and expect an error


For example:

Updaterecord1.png

How to write

  UPDATE RECORD 
  !|Update Record|
  |*Table*       |C_bpartner           |
  |*Where*       |c_bpartner_id=10000  |                                                                        
  |*Update*      |                     |
  |IsActive      |Y                    | 
  |Description   |TEST                 |
  UPDATE RECORD
  !|Update Record      |
   |*Table*            |C_bpartner            |
   |*Where*            |c_bpartner_id=10000   |                                                                        
   |*Update*Error*     |No record found       |
   |IsActive           |Y                     |     
   |Description        |TEST                  |

Delete Record


This fixture allows to update a register

Parameters:

  • *Table* : Name's table
  • *Where* : Some condition that return just one register


Command to execute

  • *Delete* : To execute the fixture and delete
  • *Delete*Error* : To execute the fixture and expect an error


For example:

Deleterecord1.png

How to write

 DELETE RECORD
 !|Delete Record|                                                                              
 |*Table*       |C_bpartner         |
 |*Where*       |c_bpartner_id=120  |                                                                        
 |*Delete*      |                   |
  DELETE RECORD
  !|Delete Record   |
   |*Table*         |C_bpartner                                                                   |
   |*Where*         |c_bpartner_id=120                                                            |                                                                        
   |*Delete*Error*  |ERROR: update o delete en «c_bpartner» viola la llave foránea                |
Cookies help us deliver our services. By using our services, you agree to our use of cookies.