NBi icon indicating copy to clipboard operation
NBi copied to clipboard

Multiple checks for a query execution

Open Nisha3297 opened this issue 4 years ago • 4 comments

Hi,

I have a requirement where i need to check multiple things to mark the test case as pass. The scenario is as follows:

  1. A query will be executed on DWH say "Query_1"
  2. From the result set of Query_1 execution, i need to assert the row count should be equal to 1
  3. One of the value of column say "Column_1A" should be equal to 500
  4. Another query need to be executed say "Query_2" 5 Two columns of Query_1 say "Column_1B" & "Column_1C" need to be compared with two columns of Query_2 say "Column_2B" & "Column_2C" 6 If the value of Column_1B is equal to value of Column_2B and value of Column_1C is greater than or equal to the value of Column_2C then test case is pass.

Checked the documentation but couldn't find how to achieve this requirement. Really appreciate if i can get any support to achieve this requirement.

Code would be something like this:

TestSuite_1 SELECT * from table_name1 1 500 SELECT * from table_name2 SELECT * from table_name2

Nisha3297 avatar Jul 31 '20 14:07 Nisha3297

image

Nisha3297 avatar Jul 31 '20 15:07 Nisha3297

Hi, I don't know if I fully understood your requirement. In case you want to compare two fields, you can do so and if it needs to be one row, it's either implicit by just having one resulting row (at least on the assert side) or you could write an extra test which asserts the rowcount to 1? From what I can tell, you might add many requirements into one complex test case where you could split it up and keep it simple? I might misunderstand, however.

FuegoArtificial avatar Aug 01 '20 08:08 FuegoArtificial

Thank you for your response.

My requirement is to test all the above mentioned 6 criterion in one test case. However if that is not possible then i have to split it into multiple test cases. Really appreciate if the code to compare two result sets for "more than or equal to" comparison can be shared as the below code is not working for me: Condition - If the value of Column_1C (from 1st result set) is greater than or equal to the value of Column_2C (from 2nd result set) then test case is pass. image

Nisha3297 avatar Aug 03 '20 09:08 Nisha3297

NBi doesn't support more than one assertion by test. It's in fact a poor practice to do than in unit testing.

Seddryck avatar Sep 13 '20 08:09 Seddryck