Perform Arithmetic and Logical assertions on two writeables/tables

CharanyasvCharanyasv Posts: 11

I have to implement the below scenario:
I have to compare the DB values from 2 different tables and perform logical and arithmetic operations on them.

Steps implemented:

  1. Create a new test suite
  2. Create a DB tool and query to fetch data (multiple columns) from a table 1. I need to save the run time values. I created a Writable A data source and saved the results.
  3. Create another DB tool and query to fetch data (multiple columns) from table 2. I need to save the run time values. I created a Writable B data source and saved the results.
  4. Now I need to perform arithmetic and logical operations on these columns of same writable or columns of different writable A & B.
    5.Need to validate these scenarios :
    i) sum the values in one column of table 1 and compare the sum is equal to a value in table 2 .
    ii) Value in a cell of table 1 and table 2 should be same

How do I include the assertions to perform the validations.
Please guide me with ideal approach to achieve this.

Comments

  • benken_parasoftbenken_parasoft Posts: 671 ✭✭✭
    edited December 2018

    i) sum the values in one column of table 1 and compare the sum is equal to a value in table 2 .
    ii) Value in a cell of table 1 and table 2 should be same

    From an Extension tool, you could script a method to do the desired validation. The second argument to your method should be of type com.parasoft.api.ScriptingContext. SOAtest will pass a ScriptingContext object to your script, which has methods for accessing data source columns. In particular, you should call the getValues(String dataSourceName, String columnName) method to return a list of all values from the desired column in table 1. In your script, you would iterate through that list to add up the values. You can similarly use that same "getValues" method to access values in table 2.

    To report errors from your script, your Extension tool could return false or call one of the "report" methods on the same ScriptingContext object. Javadocs for SOAtest's scripting API are available from Help > Contents.

Sign In or Register to comment.