Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Apex Code Coverage WlytechNew to Visual Studio Code? Get it now.
Apex Code Coverage Wlytech

Apex Code Coverage Wlytech

Wlysses Cerqueira

|
23 installs
| (4) | Free
Compares current branch with main and shows code coverage in package.xml
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🚀 sfdx-wly - Salesforce DX Coverage & Change Analyzer

Marketplace Version Downloads Rating

Digite Ctrl + Shift + P:

Logo da extensão

Online Example

A powerful Visual Studio Code extension that helps Salesforce developers to:

  • 📊 View Apex code coverage directly in package.xml
  • 🔍 Compare changes between your current branch and main
  • 🧪 List related test classes
  • 📦 Automatically generate ApexTestSuite.xml files for executions and rollbacks

✨ Features

🔁 Comparison with main branch

Identifies apex files modified or added between the current branch and main using simple-git.

📊 Apex Code Coverage in package.xml

Displays coverage percentage as a colored badge:

  • 🟢 ≥ 75%
  • 🔴 < 75%

All this without modifying the file’s original content.

🧪 Automated Test Identification

Detects test classes with @isTest and associates coverage using @coverage ClassName.

🧾 Test XML Generation

Generates two XML files:

  • Full Suite containing all detected test classes
  • Rollback Suite with only the relevant modified tests

🧪 @coverage Example

/*
 * @coverage AccountController
 * @coverage OpportunityHandler
*/

@isTest
private class AccountControllerTest {
    ...
}

🔄 DevOps Integration

Using the @coverage annotation allows CI/CD tools to automatically identify which test classes are related to the Apex files changed in a Pull Request.

This enables:

  • 🧪 Selective test execution during pipelines
  • 🚀 Faster and safer deployments
  • 🧠 Reduction of false negatives by skipping unnecessary executions

Perfect for automated pipelines in Azure DevOps, GitHub Actions, GitLab CI, and other CI platforms.


💼 Use Cases

  • ✅ Validate the impact of Apex changes before committing
  • ✅ View coverage without leaving VS Code
  • ✅ Run only the tests affected by recent modifications
  • ✅ Speed up deployments and rollbacks in Salesforce environments

📦 Available Commands

Command Description
sfdx.wly.compareWithMain Compares files with the main branch and shows coverage & tests
sfdx.wly.updateCoverageInPackage Show coverage display in the package.xml file

🧠 How It Works

  • The extension activates when you open the project
  • Coverage is queried via SOQL from ApexCodeCoverageAggregate using sfdx
  • Data is shown:
    • In an interactive HTML WebView grouped by folder
    • Directly in package.xml via visual decoration

🖼️ Visual Example

<members>AccountContractDAO</members> 🔴 42%
<members>GenericWrapper</members>     🟢 87%

📂 File Panel

📁 src/force-app/main/default/classes
  ✏️ AccountContractBizService.cls 🔴 47%
      🧪 AccountContractBizServiceTest.cls

⚙️ Requirements

  • Salesforce CLI (sfdx) installed and authenticated
  • Git configured with a main branch
  • Standard Salesforce DX folder structure

📁 Recommended Structure

📦 manifest/
   └── package.xml
📦 force-app/
   └── main/
       └── default/
           └── classes/
               ├── AccountController.cls
               ├── AccountControllerTest.cls

🧩 Recommended Extensions

  • Salesforce Extension Pack
  • GitLens
  • Apex Replay Debugger

🛠️ Contribution

Contributions are welcome!
Feel free to open issues, pull requests, or suggest improvements.

👥 Contributors

We thank the following contributors who helped make this project a reality:

Name GitHub Contribution
Wlysses wlyssescerqueira Salesforce development

How to Contribute

Send a e-mail to wlysses@gmail.com

License

This project is licensed under the MIT License.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft