mulemule4munit

Munit 2.1 mock a Map response and reference it as file


How to mock a Map response in munit2 if I would like to reference a file. For example in db connector. I tried

#[MunitTools::resultOfScript('mockExamples/singleStudentGet.groovy')]

and

#[resultOfScript('mockExamples/singleStudentGet.groovy')]

The later used to work in munit1.2 but is not working in munit2.

Please help.


Solution

  • Using resultOfScript() doesn't seem to be supported in MUnit 2.x. As an alternative you could migrate the Groovy script to a DataWeave script. See the docs at https://docs.mulesoft.com/munit/2.2/mock-file-cookbook#mocking-files-using-variables-in-a-dataweave-module for an example of how to use DataWeave scripts in MUnit 2.