Skip to content

Commit fa6d404

Browse files
committed
Mocking
1 parent f0d717c commit fa6d404

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

website/src/pages/critique.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ SOQL Lib builds a query string and passes it to the `Database.queryWithBinds` me
9595

9696
Not much. While dynamic code can be CPU-intensive, we've run extensive performance tests (full results coming soon). Here's a preview:
9797

98+
### Result Functions
99+
98100
Building a complex query dynamically with SOQL Lib consumes less than **2ms**, and around **1ms** for simple queries.
99101
Even if you execute 100 complex queries in one transaction (101 SOQL queries per synchronous transaction), in the worst-case scenario, SOQL Lib uses only ~200ms out of the 10,000ms CPU limit available.
100102

@@ -115,6 +117,16 @@ The SOQL Lib version is approximately 2x faster because we use internal aggregat
115117
Set<String> accountNames = SOQL.of(Account.SObjectType).toValuesOf(Account.Name);
116118
```
117119

120+
### Mocking
121+
122+
How long does it take to run Apex unit tests with all test data inserted? Typically seconds, or even minutes.
123+
124+
How long does it take to run Apex unit tests when query results are mocked and there's no need to create test data? Milliseconds to seconds—definitely not minutes.
125+
126+
I don't need to emphasize the benefits of writing fast, reliable unit tests. Instead of spending time figuring out how to set fields so validation rules pass, or determining what setup is needed to avoid trigger errors, mocking allows you to return query results without any database operations.
127+
128+
With mocking, you not only save hours on test data creation but also reduce test execution time by minutes. If someone argues that SOQL Lib consumes CPU time, they should consider that they cannot afford NOT to mock query results.
129+
118130
## It's Just a Query Builder
119131

120132
No, it's much more than that.

0 commit comments

Comments
 (0)