Search code examples
unit-testingpeoplesoftpeoplesoft-app-engine

PeopleSoft Testing - Catch CreateProcessRequest error


I'm currently conducting component testing rn and one of the test conditions is to catch the error of CreateProcessRequest. I have this code:

/define run control parameters – see code below/

Local ProcessRequest &RQST;

&RUN_PO_BU = PO_HDR.BUSINESS_UNIT;

&RUN_PO_ID = PO_HDR.PO_ID;

&RUN_OPRID = PO_PNLS_WRK.OPRID;

&RunCntlID = "PS_PO_" | &RUN_PO_BU | &RUN_PO_ID | "_" | UniqueRunCntlID();

&MI_SQRProcess = "Test";

&RQST = CreateProcessRequest("SQR Process", &MI_SQRProcess);

&RQST.RunControlID = &RunCntlID;

&RQST.Schedule();

&instanceList = &RQST.ProcessInstance;

If &RQST.Status = 0 Then

    <do something>;

Else

 Error MsgGet(99999, 99999, "%1 process with instance %2 returned a non->zero exit code(%3)", &MI_SQRProcess, &instanceList, &RQST.Status);

End-If;

So, my question is what am I going to do (process) to let CreateProcessRequest ran to error (or return a non-zero exit code) or how does that work so I can create a condition and test it. Thanks :)


Solution

  • What I'm trying to do is to let my code ran to error so that I can catch it for my testing. How would I let the CreateProcessRequest return a non-zero exit code.

    If I understand correctly, it sounds like you want to know how to cause &RQST.Status to contain a non-zero value (i.e. an error).

    Have you tried passing in faulty parameters when instantiating the object?

    Looking at PeopleBooks, CreateProcessRequest() is followed by Schedule(), which returns a value of 0 upon success.

    The schedule() documentation says

    • If you’re scheduling a single process, you must assign values to the following properties:
      • RunControlID
      • ProcessName
      • ProcessType

    Have you tried running schedule without setting a RunControlID?

    what happens if you comment out this line?

    &RQST.RunControlID = &RunCntlID;