How do I send MySQL queries to a database within a test?
Hello everyone,
I am currently testing a POS software that works on the side with a MySQL 5.5 MyISAM engine type database. Within my project I have several tests that I can do. The program is working perfectly, but I would like to add (I think it is a called) a script to delete everything I did in the software that is kept in the database. How would I go about doing this? I'm too educated in software programming, but willing to learn the easy stuff. Basically I would want to do a simple MySQL query like "TRUNCATE TABLE tablename". But from my research it seems that I would need to use a programming language to do this. Also, I would need to insert the database connection information so this query could be performed. Can someone go into a little detail as to how I can do such a task in the Test complete application?
Lastly, I would want this to run at the end of a "test" with my project so I can constantly re-run the "test" within the project whenever I want to, without actually having to delete the mysql queries that were performed while using the application.
Thank you!
I'm assuming, to date, you've been using mainly Keyword Tests to create your project.
It is not impossible to do SQL queries and stuff in KeywordTests... but I find it cumbersome. It feels much easier and intuitive to me to use, as you mention, "a programming language".
When you created your project, you selected a programming language. Even though you aren't using it to write your tests, you've already taken that step.There are some examples showing, briefly, how to do this... check out https://support.smartbear.com/viewarticle/18441/
I also created a Script Extension some time back that does what you want...I don't have any documentation written up for it (yet) but, if you want to try it, you can download it at https://bitbucket.org/tristaanogre/tabledrivenframework/downloads/SQLUtilities.tcx and then just send me a private message for how to use it.
But yes... to do a TRUNCATE TABLE you're going to want do something a bit more than just a keyword test.