Run All Tests fails to show result when @testSetup method is failing
See original GitHub issueSummary
Run all Tests command fails to show exception messages when the @TestSetup
method is generating an exception.
I have the flag for retrieving code-coverage enabled.
Steps To Reproduce:
- Create a new Test class with a
@TestSetup
method and add one or more@isTest
methods - Make sure the
@TestSetup
method will fail to insert data (it has to raise an exception at runtime, in our case was a new validation rule breaking our test setup) - Clink on the Run All tests link within the test class
Expected result
You should get the exception message
Actual result
You get this:
11:28:15.972 Starting Run Apex Tests
WHERE ApexClassorTriggerId IN ()
^
ERROR at Row:1:Column:162
unexpected token: ')'
VS Code Version: 1.51.1
SFDX CLI Version:
$ sfdx --version
sfdx-cli/7.82.0-3d0c527ac6 darwin-x64 node-v12.18.3
$ sfdx plugins --core
@oclif/plugin-autocomplete 0.3.0
@oclif/plugin-commands 1.3.0 (core)
@oclif/plugin-not-found 1.2.4 (core)
@oclif/plugin-plugins 1.9.4 (core)
@oclif/plugin-warn-if-update-available 1.7.0 (core)
@oclif/plugin-which 1.0.3 (core)
@salesforce/analytics 0.23.0
@salesforce/lwc-dev-server 2.9.0
├─ @oclif/plugin-help 2.2.1
└─ @oclif/plugin-update 1.3.9
@salesforce/sfdx-trust 3.4.3 (core)
alias 1.1.3 (core)
analytics 1.12.1 (core)
auth 1.3.0 (core)
config 1.2.1 (core)
generator 1.1.3 (core)
salesforcedx 50.7.0 (core)
├─ schema 1.0.1 (core)
├─ @salesforce/sfdx-plugin-lwc-test 0.1.7 (core)
├─ apex 0.1.4 (core)
├─ templates 50.1.0 (core)
├─ custom-metadata 1.0.10 (core)
└─ salesforce-alm 50.7.0 (core)
sfdx-cli 7.82.0 (core)
OS and version: Mac OS Mojave
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
testsetup will work in all test classes? - Salesforce Developers
Hi, Document says: Methods defined with the @testSetup annotation are used for creating common test records that are available for all test ......
Read more >Unit Tests failing when I Run All Tests but pass when I Debug
The failing tests share a resource that affects them all when tested together. Recheck the affected tests and their subjects.
Read more >Testing in Go: Failing Tests - Ilija Eftimov
Every test function has the format TestXxx , where Xxx must not start with a lowercase letter. The testing package exposes two different...
Read more >unittest — Unit testing framework — Python 3.11.1 ...
The final block shows a simple way to run the tests. unittest.main() ... Output is echoed normally on test fail or error and...
Read more >Unit testing fundamentals - Visual Studio (Windows)
... and efficient way to run your unit tests and view their results. ... balance will fail (The following code shows an MSTest...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @maaaaarco thanks for reporting this! With the last release we made some updates to the Apex test framework that seem to be causing these issues. I was able to reproduce the exception that gets thrown when the
@TestSetup
method fails and I see the tests running if code coverage is toggled off. However, all of the tests do seem to be correctly failing once the code coverage setting is off. We’ll keep working on this and will post back with any updates!As a workaround, since this feature is still in Beta, you can go back to the old behavior by going into your Preferences and turning off the
Salesforcedx-vscode-core › Experimental: Use Apex Library
setting.The last issues related to test information not showing when using the setting
salesforcedx-vscode-core.experimental.useApexLibrary
have been addressed in version 51.2.0 of the extensions. Thanks for providing feedback.