Timeline for Test Coverage issue for a simple rest-service class
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 29, 2023 at 7:20 | history | became hot network question | |||
Aug 29, 2023 at 0:42 | comment | added | Derek F |
That error message happens because SOQL always returns a List<SObject> . Salesforce is nice enough to let us assign the result of a query to a single SObject instance (Account in your case) when the query returns exactly one row. If it returns 0 rows or 2+ rows, you'll get an error (List has no rows/more than one row for assignment to SObject).
|
|
Aug 29, 2023 at 0:11 | vote | accept | user9035826 | ||
Aug 28, 2023 at 23:54 | comment | added | user9035826 | Only the return statement is showing red. I did notice that the log shows an error "List has no rows for assignment to SObject". No sure what this means. When I ran the query using query editor, it returns an account with 3 contacts. I also verified the endpoint through Workbench. The same account/contacts info is returned successfully. | |
Aug 28, 2023 at 23:37 | answer | added | sfdcfox♦ | timeline score: 1 | |
Aug 28, 2023 at 23:33 | comment | added | Derek F |
If you're running tests using the Salesforce CLI, then you should run sf apex run test with the -c flag to get information about code coverage. If you're running tests through the Developer Console, then you can run the test from there, open the AccountManager class, then click the "Code Coverage: None" dropdown, select "All Tests", and you'll see the uncovered lined highlighted in red.
|
|
S Aug 28, 2023 at 23:17 | review | First questions | |||
Aug 29, 2023 at 0:15 | |||||
S Aug 28, 2023 at 23:17 | history | asked | user9035826 | CC BY-SA 4.0 |