function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MUSFAR KT 6MUSFAR KT 6 

test class help is needed

public class Promise implements Finalizer, Queueable {


    private Function resolve;

    private Function reject;

    private Promise next;

    private Function last;

    private Function onError;

    private Object result;

    private Object arg;



    public Promise(Function resolve, Function reject) {
        this.resolve = resolve;
        this.reject = reject;
    }

    public void execute(System.QueueableContext ctx) {
        System.attachFinalizer(this);
        result = this.resolve.apply(this.arg);
    }

    public void execute(System.FinalizerContext ctx) {

    }

    public Promise then(Promise promise) {
        if(this.next != null) {
            this.next = next;
        } else {
            this.next.then(promise);
        }
        return this;
    }

    public void setArg(Object arg) {
        this.arg = arg;
    }

    public Promise onCatch(Function onError) {
        this.onError = onError;
        return this;
    }
    
}
SwethaSwetha (Salesforce Developers) 
HI Musfar,
I am trying to save this apex class but I am seeing the errors -"Invalid type: Function" and "Variable does not exist: resolve".

On a general note, the below articles give a good insight into how to begin writing test class and how coverage can be improved

https://salesforce.stackexchange.com/questions/244788/how-do-i-write-an-apex-unit-test
https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines 

Examples: 
https://salesforce.stackexchange.com/questions/149541/how-to-write-test-class-for-chained-enqueued-jobs/149548
https://salesforce.stackexchange.com/questions/310307/in-an-unit-test-for-an-lwc-how-can-i-prove-an-async-chain-is-setting-a-value-in

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you