logger icon indicating copy to clipboard operation
logger copied to clipboard

2 logger unit tests fail

Open xixiaofinland opened this issue 5 years ago • 2 comments

I deployed the solution into a scratch org and 2 unit tests fail

  • sendLog_UserBasedLogging_Success

  • logTrigger_AllVariations_Success line 194, there shouldn't be any logEntry in database, why assert 1?

xixiaofinland avatar Feb 24 '20 13:02 xixiaofinland

Also mentioned in #9

Thanks for being patient @xixiaofinland and @arafesthain

I checked out the code as is, pushed, assigned permset, and ran the tests successfully.

08:47:25.675 sfdx force:apex:test:run --classnames LoggerTest --resultformat human --outputdir /Users/szandor/dev/logger/.sfdx/tools/testresults/apex --loglevel error
=== Test Reports
FORMAT  FILE
──────  ────────────────────────────────────────────────────────────────────────────────────────────
txt     /Users/szandor/dev/logger/.sfdx/tools/testresults/apex/test-result.txt
txt     /Users/szandor/dev/logger/.sfdx/tools/testresults/apex/test-run-id.txt
junit   /Users/szandor/dev/logger/.sfdx/tools/testresults/apex/test-result-7071j00000qIbon-junit.xml
json    /Users/szandor/dev/logger/.sfdx/tools/testresults/apex/test-result-7071j00000qIbon.json

=== Test Results
TEST NAME                                              OUTCOME  MESSAGE  RUNTIME (MS)
─────────────────────────────────────────────────────  ───────  ───────  ────────────
LoggerTest.disabledLogging                             Pass              19
LoggerTest.getLogJSON_Success                          Pass              20
LoggerTest.handleJSONLength_Success                    Pass              19
LoggerTest.LogEntry_Constructor_Success                Pass              209
LoggerTest.logException_Success                        Pass              18
LoggerTest.logTrigger_AllVariations_Success            Pass              213
LoggerTest.log_MessageGiven_Success                    Pass              18
LoggerTest.log_setLogEntryAttributes_Success           Pass              17
LoggerTest.log_setMethodName_Success                   Pass              18
LoggerTest.popAll_DecrementsLogLevel_Success           Pass              54
LoggerTest.pop_DecrementsLogLevel_Success              Pass              21
LoggerTest.printLog_Success                            Pass              20
LoggerTest.push_IncrementsLogLevel_Success             Pass              19
LoggerTest.push_setMethodName_Success                  Pass              21
LoggerTest.sendLog_Fail_EnableLoggingBeatsSaveAllLogs  Pass              59
LoggerTest.sendLog_Fail_InvalidTrace                   Pass              62
LoggerTest.sendLog_Success                             Pass              260
LoggerTest.sendLog_UserBasedLogging_Success            Pass              195

=== Test Summary
NAME                 VALUE
───────────────────  ──────────────────────────────────────────────────────────────
Outcome              Passed
Tests Ran            18
Passing              18
Failing              0
Skipped              0
Pass Rate            100%
Fail Rate            0%
Test Start Time      Jul 31, 2020 8:47 AM
Test Execution Time  1262 ms
Test Total Time      1262 ms
Command Time         5368 ms
Hostname             https://agility-business-6530-dev-ed.cs102.my.salesforce.com/
Org Id               00D1j0000001d2SEAQ
Username             [email protected]
Test Run Id          7071j00000qIbon
User Id              0051j000004GhasAAC

I need a reproduction if this issue persists.

Szandor72 avatar Jul 31 '20 06:07 Szandor72

Thanks @Szandor72, in my opinion permission set should be assigned to a test user and then test run as this user to not be dependent of current running/deploying one (hence more CI/CD friendly)

arafesthain avatar Aug 10 '20 11:08 arafesthain