Search code examples
mavenmulemule-studiomunit

MUnit test error in Anypoint Studio when project is using Maven


I am trying to introduce MUnit unit tests to an existing Mule project which is using Maven for builds and dependency management.

However I am unable to run the tests visually through Mule Anypoint Studio, when I try to debug them I get the error:

MUnit test could not be run, The Archive C:/pathtomyuserfolder/.m2/commons-logging/1.2/commons-logging-1.2.jar which is referenced by the classpath, does not exist.

I can however run the test using Maven using the command "mvn test" but this is not ideal as I want to be able to debug the test, pausing at breakpoints etc.

I can reproduce this problem using the Mule Anypoint Exchange sample here: https://www.mulesoft.com/exchange/#!/munit-example. When I open this project I can debug the tests with no problems, but if I then right click on the project and select Maven Support In Studio -> Mavenize. I am then unable to debug the tests in Studio.

What am I doing wrong? Is this behavior supported?


Solution

  • This turned out to be a problem with the build path on my machine and nothing to do with MUnit.

    The clue was in the actual error message above - that the path was missing the /repository folder under my /.m2 folder. I'm not sure how it happened by my M2_REPO was pointing to the wrong level.

    The strange thing is that the two projects I tried would still actually run ok, so that's why I thought it was just a problem with MUnit. Sorry for the confusion and thanks to @Ryan and @Dds for your comments. I should have first tried to fix the problems highlighted in Mule Studio before posting.