I would like to check if there is any plugin that exists for running mocha test cases in maven test phase, and to return BUILD SUCCESS or FAILURE based on test result
-lucky
I was interested in the question too. I'm testing the nodejs code, so it may be not very relevant. No success so far discovering the plugin I need, but if you need only the failing build process you can use maven-antrun-plugin like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>test-nodejs</id>
<phase>test</phase>
<configuration>
<tasks name="Run mocha tests">
<exec dir="${basedir}"
executable="npm"
failonerror="true">
<arg value="test"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Pay attention to failonerror argument.
One more thing to note (in case of NodeJS) - you need to setup the package.json file to support npm test
command, e.g.
"scripts": {
"test" : "mocha -R tap"
},
and your tests should reside in test folder. Also, mocha treats subfolder well enough, so you can make reasonable test case folder structure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With