Klov报告:如何在MongoDB中查看生成的报告?附配置代码
Hey there! Let's walk through exactly how you can access and view your Klov report data directly in MongoDB, based on the configuration snippet you shared.
1. Connect to Your Local MongoDB Instance
First, you'll need to connect to your MongoDB server (running at localhost:27017 as per your setup) using either the MongoDB command line tool (mongosh) or a GUI like MongoDB Compass.
Using mongosh (Command Line)
Open your terminal/command prompt and run this command to connect:
mongosh "mongodb://localhost:27017"
Using MongoDB Compass (GUI)
- Launch MongoDB Compass, paste the connection string
mongodb://localhost:27017into the connection field, and click Connect.
2. Locate Klov's Database and Collections
Klov automatically creates a dedicated database and collections to store report data. Here's what you need to look for:
- The default database name Klov uses is
klov - Collections are organized around your project (
CsharpReportsfrom your config):projects: Stores basic info about your test projects (you'll find yourCsharpReportsentry here)reports: Holds details for each build report (yours is namedBuild [timestamp])tests: Contains individual test case results, linked to their parent report
3. Query and Inspect the Data
View Your Project Details
Switch to the klov database and query the projects collection to find your CsharpReports entry:
use klov db.projects.find({ "name": "CsharpReports" })
This will return your project's metadata, including a unique _id that links to related reports.
Find Your Specific Build Report
To locate the report you generated (with the name Build [datetime]), run this query on the reports collection:
// Match any report starting with "Build " db.reports.find({ "name": /Build / }) // Or use the exact report name for precision (e.g., "Build 2024-05-20 14:30:00") db.reports.find({ "name": "Build 2024-05-20 14:30:00" })
The result will include details like the report's creation time, linked project ID, and references to all test cases in that build.
View Individual Test Case Results
To see the execution details of specific tests, use the report's _id (from the reports query) to filter the tests collection:
// Replace "your-report-id-here" with the actual _id value from your report db.tests.find({ "reportId": ObjectId("your-report-id-here") })
This will show you each test's status, duration, logs, and any attached screenshots or artifacts.
Quick Side Note: Klov UI for Visualized Reports
While your question focuses on MongoDB, I should mention that Klov comes with a built-in web UI for easier, visual report browsing. A quick check: your config sets KlovUrl = "http://localhost:27017"—typically, Klov UI runs on port 5687 by default, so you might want to verify that. If configured correctly, accessing the Klov URL in your browser will give you a user-friendly view of your test reports without needing to dig into MongoDB directly.
内容的提问来源于stack exchange,提问作者Magesh

