Apex Test Results Viewer
A Visual Studio Code extension to visualize Salesforce Apex test results from JSON files in an interactive, user-friendly interface. This extension allows developers to upload test result JSON files generated by Salesforce's sf apex run test command, displaying key performance indicators (KPIs), slowest tests, failing tests, and a detailed DataTable with export capabilities.

Screenshots
Features
- Upload JSON: Load Salesforce Apex test result JSON files using VS Code's file picker.
- Sample Data: Load a sample test result JSON for quick testing.
- Interactive UI: View test results in a responsive DataTable with sorting, searching, and CSV export.
- KPIs: Display total tests, passed, failed, pass rate, and test run details.
- Quick Lists: See the top slowest tests and failing tests at a glance.
- Theme Support: Toggle between light and dark modes, with persistence across sessions.
- Local Processing: All data processing happens locally in VS Code; no data is sent to external servers.
Requirements
- Visual Studio Code version 1.80.0 or higher.
- A Salesforce Apex test result JSON file (e.g., generated via
sf apex run test -o username -w 15 -r json > output.json ).
Usage
Open the Viewer:
- Press
Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the Command Palette.
- Type and select
Apex Test Results: View Results .
Load Test Results:
- Click Upload JSON to select a Salesforce test result JSON file using the VS Code file picker.
- Alternatively, click Load Sample to view sample test data.
Interact with Results:
- KPIs: View total tests, passed, failed, pass rate, and test run details.
- Slowest Tests: See the top 6 slowest tests with their run times.
- Failing Tests: Review up to 8 failing tests with their error messages.
- DataTable: Browse all test results with sorting, searching, and CSV export options.
Toggle Theme:
- Click the Dark or Light button to switch themes, with preferences saved across sessions.
Clear Data:
- Click Clear to reset the viewer and remove loaded data.
Example JSON File
To generate a compatible JSON file, run the following Salesforce CLI command:
sf apex run test -o username -w 15 -r json > output.json
The JSON should include a summary object (with fields like testsRan , passing , failing , passRate , etc.) and a tests array containing test details (e.g., MethodName , Outcome , RunTime , Message , StackTrace ).
Known Issues
- The extension relies on external CDNs for jQuery, DataTables, and Tailwind CSS. Ensure an internet connection is available when using the viewer.
- Large JSON files may impact performance due to client-side processing.
License
This project is licensed under the MIT License. See the LICENSE file for details.
**Happy Apex Testing! 🎉 **
| |