0

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 :)

Community
  • 1
  • 1
jackono
  • 3
  • 2
  • "what am I going to do to let my program execute the else statement for my testing for me to show that it will catch the error." I don't understand the question. What is the current behavior of the code? What is your expected behavior from the code? What do you want it to do that it isn't already doing? – qyb2zm302 Jan 10 '18 at 05:32
  • There is no problem to the code. 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. – jackono Jan 10 '18 at 06:05

1 Answers1

0

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;

qyb2zm302
  • 6,458
  • 2
  • 17
  • 17
  • 1
    That's very helpful of you. I think that gave me some idea how to test this. I can just mess some data backend for those values for it to return an error. Since I need to do the testing without changing any of the codes because once this is migrated and needs testing on a higher environment, code change would not be possible. But this input is very helpful. Thanks man! – jackono Jan 11 '18 at 10:06