Skip to content

Releases: beyond-the-cloud-dev/async-lib

Context Mocking for Queueable Jobs

31 Jan 13:02
13fdb95

Choose a tag to compare

New Features

Context Mocking with AsyncMock

Test your async jobs with full control over QueueableContext and FinalizerContext. No more limitations when testing error handling paths or finalizer behavior.

@IsTest
static void shouldHandleJobFailure() {
    AsyncMock.whenFinalizer('error-handler')
        .thenThrow(new DmlException('Parent job failed'));

    Test.startTest();
    Async.queueable(new MyJob()).mockId('error-handler').enqueue();
    Test.stopTest();
}

Key capabilities:

  • whenQueueable() / whenFinalizer() - Setup mocks by mockId
  • whenQueueableDefault() / whenFinalizerDefault() - Default fallback mocks
  • thenReturn() / thenThrow() - Configure success or exception responses
  • Queue-based mock consumption for testing multiple invocations
  • Direct unit testing without Test.startTest()/stopTest()

mockId Builder Method

New mockId(String) method on QueueableBuilder to identify jobs for mocking.

Improvements

  • Renamed QueueableChainBatch to QueueableChainSchedulable
  • Added namespace checks when adding QueueableJobSetting metadata
  • Improved API documentation with structured tables for result properties

Documentation

AsyncMock API - Complete reference
Testing Async Jobs - Patterns and best practices

Soft and deep job cloning.

08 Nov 19:15

Choose a tag to compare

This release introduces:

  • Soft and deep Clone of the Job - Enhanced QueueableBuilder with .deepClone() method for complete object isolation when working with complex object relationships. Learn more here.

Fix chaining job issue

05 Nov 22:23

Choose a tag to compare

This release introduces:

  1. Fix for skipping chained jobs from the same context by cloning passed job.

On demand Queueable Job chaining and result enhancements

11 Oct 16:27

Choose a tag to compare

This release introduces:

  1. New QueueableBuilder.chain() methods - chain() and chain(QueueableJob job), which allowing you to manually add jobs to an existing chain. You can now decide when to chain jobs — not just rely on the automatic chaining mechanism triggered when platform limits are hit.
  2. Enhanced Results from QueueableBuilder enqueue(), chain(), and chain(QueueableJob job) now return the Queueable Chain State. Additionally, enqueue() indicates whether the action created a new chain, continued an existing chain, or scheduled an initial job.
    → Learn more here.
  3. Access Queueable Chain State On-Demand
    Use Async.getCurrentQueueableChainState() to inspect the current chain — including all chained jobs, next job IDs, and chain type.

v2.0.0

01 Oct 09:21

Choose a tag to compare

This release introduces:

  1. Change of initial job start, from 'Database.executeBatch()' to scheduling it in 1 minute in the future, due to issues related when using Queueable Jobs in Batches. Full explanation can be found here.
  2. New ScheduleableBuilder method skipWhenAlreadyScheduled() that allows scheduling only if the job with the same name is not already scheduled. More info here.
  3. Minor enhancements.

v1.0.0

24 Aug 16:19

Choose a tag to compare

documentation