Skip to main content
Level 2
May 17, 2016

Unit Testing for Custom workflow process and Participant step??

Hi Team,

Can we write unit test cases for Custom workflow process and Participant step?? using Junit or Jmockito

If Yes could you please help me out.

I tried using Jmockito and junit

 @Test
  public void testExecute() throws WorkflowException, RepositoryException {

    try {
      new NonStrictExpectations() {
        {
          args.get("PROCESS_ARGS", String.class);
          returns("gen7flag");

          wfSession.adaptTo(Session.class);
          returns(session);

          wfItem.getWorkflowData();
          returns(workflowData);

          workflowData.getPayload();
          returns("/content/corning/worldwide/en/handle-bar");
          
        }
      };

      previewUnpublish.execute(wfItem, wfSession, args);

    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }

But in previewUnpublish Workflow process i have a replicator variable referenced, how can mock as its part of workflow class object i cant pass it as param arg

@Reference
  private Replicator replicator;

Thanks in Advance

Mallikarjun

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Level 9
May 17, 2016

Hi Mallikarjun,

From what I am aware of , you should be able to write test cases for custom workflow process.

If a replicator variable is referenced, we can do it as below [Please note : Using powermock is not recommended]

private Replicator replicator;

replicator = mock(Replicator.class);

Whitebox.setInternalState(ProcessName, "replicator", replicator);

Translate