Skip to content

Commit

Permalink
Made tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Apr 20, 2022
1 parent 04d8b4b commit bac4ce7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
20 changes: 0 additions & 20 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
Framework Catch-up
* Start-up performance might need looking at - looks like it has a linear startup time based on the number of services / domains / etc configured.

Logger
* Write up standards

Docs for Logger:
* Custom Setting - if it doesn't exist, will log everything.
* TestLoggerService
* ortoo_Exception - stripContext
* ServiceUtils.logAndRethrow
* All code other than the Contracts
* If you are returning a value, ensure you instantiate and set to a resonable default. Generally, it will never be used without being set.
* Logging standards
* How to test logging

Tests:
* Each of the services need a test for the try / catch - where possible


Licenses that are needed with the source code and binary:
* fflib - https://github.com/apex-enterprise-patterns/fflib-apex-common/blob/master/LICENSE
* fflib apex extensions - https://github.com/wimvelzeboer/fflib-apex-extensions/blob/main/LICENSE
* Amoss - https://github.com/bobalicious/amoss/blob/main/LICENSE
* SObject Fabricator - https://github.com/bobalicious/SObjectFabricator/blob/master/LICENSE




* Move all the Jest LWc tests over to create the component in the before

Look at the use of 'MockDatabase' in fflib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ private without sharing class ServiceUtilsTest
DmlException exceptionToLog = new DmlException( 'The exception to log' );
Exception exceptionCaught;

logger.clearLogHistory();
Test.startTest();
try
{
Expand All @@ -21,7 +22,9 @@ private without sharing class ServiceUtilsTest
Test.stopTest();

logger.assertNumberOfLogCalls( 1, 'logAndRethrow, when given an exception, will log it with the logger service' );
System.assertEquals( exceptionCaught, exceptionToLog, 'logAndRethrow, when given an exception, will rethrow it' );
logger.assertExceptionWasLogged( 0, exceptionToLog, 'logAndRethrow, when given an exception, will log it with the logger service' );

System.assertEquals( exceptionToLog, exceptionCaught, 'logAndRethrow, when given an exception, will rethrow it' );
}

@isTest
Expand All @@ -36,6 +39,7 @@ private without sharing class ServiceUtilsTest
Exception exceptionToLog = (Exception)exceptionController.getDouble();
Exception exceptionCaught;

logger.clearLogHistory();
Test.startTest();
try
{
Expand All @@ -48,7 +52,8 @@ private without sharing class ServiceUtilsTest
Test.stopTest();

logger.assertNumberOfLogCalls( 1, 'logAndRethrow, when given an ortoo exception, will log it with the logger service' );
ortoo_Asserts.assertEquals( exceptionCaught, exceptionToLog, 'logAndRethrow, when given an ortoo exception, will rethrow it' );
logger.assertExceptionWasLogged( 0, exceptionToLog, 'logAndRethrow, when given an ortoo exception, will log it with the logger service' );
ortoo_Asserts.assertEquals( exceptionToLog, exceptionCaught, 'logAndRethrow, when given an ortoo exception, will rethrow it' );

exceptionController.verify();
}
Expand All @@ -61,6 +66,7 @@ private without sharing class ServiceUtilsTest
Exception exceptionToLog = new Exceptions.ValidationException( 'ValidationFailed' );
Exception exceptionCaught;

logger.clearLogHistory();
Test.startTest();
try
{
Expand Down

0 comments on commit bac4ce7

Please sign in to comment.