# Create a Database Test Case

**Database testing** is a critical aspect of software quality assurance that focuses on verifying the correctness, integrity, and performance of a database system. It involves testing various aspects of the database.

Database automation testing involves creating scripts or code that can automatically execute database queries, validate results, and report on test outcomes. This can be achieved using various tools and programming languages.

### Prerequisites

* Access to the project for which you want and privilege to create data base automation test case.
* Necessary Database connection details (host, port, database name, username, password).
* SimplifyQA Wizard needs to be installed and running. Learn how to setup Wizard here [Setup QAWIzard](/simplifyqa-installation-and-setup.md).

### How to Create a Database Test Case

1. Navigate to **Test Case** from the left-hand panel.

<figure><img src="/files/iYrTxh5IH5dwFZ8NW8aR" alt="" width="201"><figcaption></figcaption></figure>

2. Click on '**+ Test Case'**.
3. From the **Automation** dropdown, select **Database**.

<figure><img src="/files/J8l32uaWhk3MuN0wC6pX" alt=""><figcaption></figcaption></figure>

4. Enter a meaningful **Test Case Name**.
5. In the **Action** section of each step, select the appropriate [database action](/introduction-to-test-management-in-simplifyqa/supported-actions.md) (e.g., *Connect to DB*).

<figure><img src="/files/Reo2il9OttO3hmZdsA8J" alt=""><figcaption></figcaption></figure>

6. In the **Parameter** section, input the required [parameters](/introduction-to-parameters/create-and-utilise-parameters-in-your-test-case.md) details which will be prompted (e.g., *Database Type, Host, Port, Username, Password, Database Name*)

<figure><img src="/files/Q5SNWd1i5IGZXuS9y1Ho" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The Test Data for the parameters can be added from the Test Data Tab. Database Type should be all in capitals e.g., POSTGRES or MYSQL.
{% endhint %}

7. After establishing the connection, you can directly input your **SQL queries**. Each query and its corresponding assertion can be saved as a separate step.
8. Arrange these steps in the desired sequence to define the test case flow.

Once all relevant steps are added, click **Save** to finalise the test case and select the appropriate module.

### Use Case: Create, Insert, Update & Validate Data in PostgreSQL Database

**Objective:**\
To validate the creation of a database table, insert multiple records, update a specific record, and confirm the update via query validation.

#### **Steps Overview:**

1. Establish Database Connection
   * DB Type: PostgreSQL
   * Host: `64.227.131.72`
   * Port: `5432`
2. Execute a SQL query to create a table named `Simplify`
3. Insert test data into the newly created table
4. Read Data for Validation
   * Use a Read Query action to retrieve current data from the `simplify` table.
   * Store the result in a Runtime Parameter for validation.
5. Update a specific record’s last name
6. Read Updated Data for VerificationExecute another Read Query to validate the updated `last_name`
   * Again, store this result in a Runtime Parameter to verify if the `last_name` has changed to `Doe-Smith`.

<figure><img src="/files/mDfQewsjzCJHhgEZuaXm" alt=""><figcaption></figcaption></figure>

**Validation Outcome:**

This test case validates:

* Successful table creation
* Accurate data insertion
* Proper update functionality
* Reliable data retrieval for assertions

Database test case in SimplifyQA empowers users to validate backend data operations efficiently without the need for complex scripting. With a user-friendly interface, support for various databases, and step-wise execution flow, testers can quickly connect to databases, run queries, assert results, and ensure data integrity.&#x20;

Whether you're validating application behavior or performing backend regression testing, SimplifyQA makes it seamless to integrate database validation into your automation strategy.

### Frequently Asked Questions (FAQs)

<details>

<summary>What types of databases does SimplifyQA support?</summary>

SimplifyQA supports all major structural and non-structural databases.

</details>

<details>

<summary><strong>Can I use multiple queries in a single test case?</strong></summary>

Yes, each query can be added as a separate step in the test case. You can organise them in the required sequence.

</details>

<details>

<summary>What if my connection fails during the test execution?</summary>

The execution log will capture connection errors. Make sure host, port, credentials, and firewall rules are correctly configured.

</details>

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.simplifyqa.ai/introduction-to-test-management-in-simplifyqa/create-a-database-test-case.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
