Database connection:
In order to show on how to operate database, here creating a sample to present through groovy script.
Structure:
1.set run properties script
2.load properties from external file
3.operating db
The First, we need to create a property file, for example: i create properties file named DB_TEST_Connectivity.properties, in this file,you can put some configuration information of db in it,as following:
url=jdbc:mysql://localhost:3306/test
driver=com.mysql.jdbc.Driver
username=root
password=*****
the Second, we will read data from properties fiel, so firstly need to find the path that properties file stored.
And then,we will load data from properties file and put them in TestSuite level so that can be shared by all of test case under test suite project, the script is following:
Lastly, we can create our sql to access database, the script is as follows: