Running Apex Tests Locally
The SquireX Apex runtime executes your Apex unit tests entirely offline โ no org, no deploy, no scratch org spin-up.
Initializeโ
cd my-salesforce-project
squirex init
Creates .squirex.json:
{
"version": "1.0",
"interpreter": "go",
"sourceDirectory": "force-app/main/default/classes",
"testPattern": "**/*Test.cls"
}
Run All Testsโ
squirex run -d force-app/main/default/classes
Run a Single Test Methodโ
squirex run --method AccountTest.testInsert
Run with Coverageโ
squirex run -d force-app/main/default/classes --coverage
Sample output:
CODE COVERAGE:
AccountController 12/15 80% โโโโโโโโโโโโโโโ
OpportunityHandler 18/20 90% โโโโโโโโโโโโโโโโโโโโ
TOTAL 30/35 86%
JUnit XML (for CI)โ
squirex run -d force-app/main/default/classes --junit results.xml
Parallel Executionโ
squirex run -d force-app/main/default/classes --parallel
warning
Parallel mode uses goroutine-based test isolation. Tests that rely on static class state may produce different results than sequential mode.
Supported Apex Featuresโ
| Feature | Status |
|---|---|
| DML: insert, update, upsert, delete, merge | โ |
| SOQL: WHERE, ORDER BY, LIMIT, OFFSET | โ |
| SOQL: GROUP BY, aggregates (COUNT, SUM, AVG) | โ |
| Governor limit tracking | โ |
| try-catch-finally | โ |
| Cross-class method calls | โ |
| Inner classes | โ |
| Method overload resolution | โ |
| Interfaces | โ |
| SOQL subqueries | โ ๏ธ Not yet |
| SOSL | โ ๏ธ Not yet |
Async (@future, Batch, Queueable) | โ ๏ธ Runs synchronously |
Example Test Classโ
// examples/AccountUtilsTest.cls
@isTest
private class AccountUtilsTest {
@isTest
static void testInsert() {
Account a = new Account(Name = 'Test Corp', Industry = 'Technology');
insert a;
Account fetched = [SELECT Id, Name FROM Account WHERE Name = 'Test Corp' LIMIT 1];
System.assertEquals('Test Corp', fetched.Name);
}
}
Run it:
squirex run --method AccountUtilsTest.testInsert