0

I'm making a test using a query (I am using Execute SQL String instead of row count for now) to count the number of rows with the following code:

*** Settings ***
Library     DatabaseLibrary
Library     OperatingSystem

*** Variables ***
${DBName}   db
${DBUser}   user
${DBPass}   password
${DBHost}   hostname
${DBPort}   port

*** Test Cases ***
Making row count
    DatabaseLibrary.Connect To Database       pymysql    ${DBName}    ${DBUser}    ${DBPass}    ${DBHost}    ${DBPort}
    ${result} =  Execute SQL String  SELECT COUNT(*) as count_id FROM myTable;  True
    should be equal as strings  ${result}   6
    Disconnect From Database

If I go to my database I return 6 rows, so the test should me passed. However, using RobotFramework I am getting the following results:

==============================================================================
Making row count                                                     | FAIL |
None != 6

Why I am using None as result? I am using Execute SQL String because I have the same code for other tests with some more complex SQL Queries.

Thanks!

1 Answer 1

1

The number of rows will be returned by Execute SQL keywords. Data returns will be done only through Query keyword. Please try to use :

${rows}=  Query   SELECT COUNT(*) as count_id FROM myTable;
should be equal as strings  ${rows}   6

or

 @{results}    Query    ${yourQuery}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.