Customizing our tests
Now we took the first steps towards running Karate in a CI/CD environment. There is one severe problem that needs to be addressed, though.
Currently, the tests won’t work without hardcoded database credentials. This is not what we want. Ideally, these should come from a secure place that can only be changed by administrators. In the next sections, we will prepare our tests for this scenario.
Passing database credentials as system properties
If you remember from the last chapter, to access our test database, we needed these parameters in the MySQL.java
class:
connectionString
: With the host and database name.user
: If you use a database from https://www.freesqldatabase.com, the user name is the same as the database name. For other database providers, this can be different, though.password
: The password for the database.
In our source code, these parameters look like this:
String connectionString = ...