Is there any "mocha maven plugin"?

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, eg

"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.

链接地址: http://www.djcxy.com/p/61406.html

上一篇: Maven自定义插件错误

下一篇: 有没有“摩卡maven插件”?