In today's fast-paced development environment, efficient monitoring and visualization of test results are essential for ensuring the quality of your application. Keploy, a zero-code testing tool, simplifies test generation and integration, but how do you effectively monitor and analyze the test data Keploy generates?
This is where Grafana, a powerful open-source analytics and monitoring platform, comes into play. In this blog, we'll explore how you can set up a Grafana dashboard to visualize Keploy test data, enabling you to quickly assess the health of your tests and debug issues efficiently.
What is Grafana?
Grafana is an open-source platform for monitoring and observability, offering interactive visualizations and dashboards. It supports multiple data sources like Prometheus, MySQL, InfluxDB, and many more, making it an incredibly versatile tool for displaying key metrics and insights.
With Grafana, you can create real-time dashboards to track everything from server performance to test results, all in one place. By combining Grafana with Keploy, you can visually monitor your test suites and gain insights into test performance, failures, and trends over time.
What is Keploy?
Keploy is an open-source, zero-code testing platform that generates and executes test cases by observing real-world network traffic. It captures API requests, responses, and user interactions to automatically create test cases without requiring developers to write test scripts.
Brownie points out that it can integrate with existing CI/CD pipelines to enable end-to-end, integration, and unit testing.
Why Integrate Keploy with Grafana?
While Keploy automates test creation and execution, visualizing the test results can sometimes be challenging, especially with large test suites. Integrating Keploy with Grafana allows you to:
Monitor test results in real-time: Get immediate insights into your test runs.
Visualize test trends: Track how your tests perform over time, including pass/fail rates and test coverage.
Analyze test failures: Quickly identify patterns and potential areas of improvement.
Share insights: Easily share dashboards with team members, providing transparency and accountability across your testing process.
Step-by-Step Guide to Using Grafana with Keploy
Step 1: Install Grafana
If you don't have Grafana yet, follow these steps:
-
Use the docker to start Grafana service:
docker run -d -p 3000:3000 --name=grafana grafana/grafana-enterprise
Access Grafana via
http://localhost:3000/
and log in with the default credentials (admin
/admin
).
Step 2: Set Up Keploy to Generate Test Data
Before integrating Grafana, you need to ensure that Keploy is generating and storing test reports. Keploy captures API traffic to create tests and stores the test results, which can then be visualized in Grafana. I am using a sample app based on Mux router with Postgres database : - https://github.com/Sonichigo/mux-sql
#Start Postgres
docker-compose up -d postgres
#Build App binary
go build -cover
You can generate test cases with Keploy by running:
keploy record -c "./test-app-product-catelog"
This command captures the real-world traffic from your application and creates test cases based on it. We can make API Calls using Hoppscotch
, Postman
or cURL
command and keploy would be able to capture those calls to generate the test-suites containing testcases and data mocks.
To run the test cases we created earlier and generate our report, let’s run :
keploy test -c "./test-app-product-catelog"
This will execute the test cases and generate test reports.
Step 3: Export Keploy Test Data
Next, you need to export the test data generated by Keploy into a format that Grafana can read. Most common being JSON format, so let’s export the test reports to JSON using JSON Converter.
Step 4: Configure Grafana Data Source
Grafana supports a wide range of data sources, and you can use one based on how you've exported your Keploy data. If you're using JSON or CSV, you can set up Grafana Loki or another time-series database that supports the format. If you store test reports in MySQL or Prometheus, configure Grafana to fetch data from that source.
Go to
Settings > Data Sources
in Grafana.Select the appropriate data source type (e.g., MySQL, Prometheus).
Configure the connection by providing the necessary credentials and database details.
Test the connection to ensure that Grafana can pull data from your source.
Step 5: Create a Grafana Dashboard
Once the data source is set up, you can create a dashboard to visualize the Keploy test results.
Go to
Create > Dashboard
in Grafana.Select
Add a new panel
.Query the test data from your chosen data source.
Configure visualizations based on your needs. Some examples include:
* **Bar charts** to display test pass/fail ratios.
* **Time-series graphs** to track test execution times.
* **Tables** to list failed tests and their details.
- Customize the panels to reflect the key metrics you want to monitor, such as:
* Total tests run
* Passed/failed tests
* Test duration
* Coverage percentage
Alternatively, you can import the existing Keploy Dashboard on Grafana with everything already in place and just upload the JSON to view the metrics.
Step 6: Automating Keploy Test Data Updates
To keep your dashboard updated with the latest test data, you can automate the process of exporting Keploy reports and updating the Grafana data source. Set up a cron job or CI/CD pipeline step to regularly export Keploy reports.
Key Metrics to Track in Your Dashboard
Here are some useful metrics to include in your Grafana dashboard for Keploy:
Total Test Runs: The number of test executions over time.
Pass/Fail Ratio: A visual breakdown of successful vs. failed test cases.
Test Execution Time: The average time it takes for tests to run, helping identify slow-running tests.
Test Coverage: Percentage of code covered by the tests, which can help you identify areas lacking coverage.
Failed Test Cases: A detailed breakdown of the specific tests that failed, including error messages and stack traces.
Conclusion
Integrating Keploy with Grafana offers a powerful combination of zero-code test automation and real-time test visualization. By creating a Grafana dashboard for your Keploy test data, you can monitor the health of your application’s test suite, track key trends, and quickly respond to any issues that arise.
This setup not only saves time but also improves transparency and accountability across your testing process, enabling your team to make data-driven decisions with confidence. So, whether you're a developer, tester, or DevOps engineer, start using Grafana with Keploy to streamline your testing and monitoring efforts.
FAQs
What benefits does integrating Keploy with Grafana offer?
Integrating Keploy with Grafana provides real-time monitoring of test results, enabling you to visualize test trends, quickly spot failures, track test execution times, and assess test coverage. It also promotes transparency, helping teams make data-driven decisions and improve testing accountability.
How does Keploy generate test cases without writing code?
Keploy automatically captures network traffic and API interactions within your application to create test cases. This zero-code approach lets you generate comprehensive test suites by simply observing real-world user interactions, saving time and eliminating the need for manually written test scripts.
What kind of data sources can I connect to Grafana to view Keploy test data?
Grafana supports various data sources such as Prometheus, MySQL, CSV, and JSON. Depending on the format of the Keploy test data, you can configure Grafana to pull data from these sources, allowing flexible and customized visualization of test metrics.
Can I automate the process of exporting Keploy test data to Grafana?
Yes, you can automate the export of Keploy test data by setting up a cron job or adding a CI/CD pipeline step. This automation ensures that Grafana receives the latest test reports regularly, keeping the dashboard metrics up to date.
What are some key metrics I should monitor in my Grafana dashboard?
Useful metrics include Total Test Runs, Pass/Fail Ratio, Test Execution Time, Test Coverage Percentage, and specific details of Failed Test Cases. These metrics help assess the overall health of your tests, identify slow-running tests, and focus on areas requiring improvement.
Is there a pre-built Grafana dashboard for Keploy, or do I need to create one from scratch?
You can import an existing Grafana dashboard for Keploy by uploading the provided JSON file. This allows you to quickly set up a dashboard with default panels and visualizations, which you can further customize based on your specific testing needs.