Ask a Question

How to implement SQL database validation in TestComplete?

mgroen2
Super Contributor

How to implement SQL database validation in TestComplete?

I want to use TestComplete to validate the results in an SQL database. Can I use TestComplete to connect to the MSSQL database, "fire" a querie to it, and validate on the results of the querie (which contains dynamic values).

 

If so, how to implement this? Can anyone help me with tips, best practices?

 

Thanks,

Mathijs

 

3 REPLIES 3
tristaanogre
Esteemed Contributor

This is a regular task for us in our automation work.

 

What I do is use the ADO object (see https://support.smartbear.com/testcomplete/docs/reference/program-objects/ado/index.html) to create connections and queries to our SQL database.  The link provides some basic examples as to how to implement the objects.  Your code may end up being more complex depending upon what you need to do.

 

I have an extension (see my signature for the link) that encapsulates some of this for easy of use.  This code simply fires the queries.  Doing the comparison is simply writing "if-then" logic to compare the result of the query with the expected values.  The expected values, if dynamic, should still be attainable in your automation.  You've created the data in the first place during the course of the automation so you should be able to construct the expected values in code.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
karkadil
Valued Contributor

Try using Database Checkpoints as explained here

AlexKaras
Community Hero

Hi Mathijs,

 

Also, the whole HowTo|SQL branch (https://support.smartbear.com/viewarticle/9013/) contains a set of useful code samples.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: