通过maven执行python单元测试时的成功代码

2024-05-04 06:53:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个使用maven构建的java/python混合项目。在构建过程中,所有单元测试都运行良好,python测试失败会在日志中报告,但是成功代码仍然是“成功”的,不受失败测试用例的影响。python & maven (unit test integration)解决了一个类似的问题,其中一个答案提到了配置元素“successCode”的用法,有人知道应该如何配置这些元素吗?在

我的尝试(无效):

<plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>exec-maven-plugin</artifactId>
       <version>1.1</version>
       <executions>
            <execution>
                <id>python unittest</id>
                <phase>test</phase>
                <goals>
                    <goal>exec</goal>
                </goals>
                <configuration>
                    <executable>${python.script}</executable>                      
    <workingDirectory>${project.basedir}/src/test/python/</workingDirectory>
                        <arguments>
                            <argument>SessionTestSuite.py</argument>
                        </arguments>
                        <successCodes>
                            <successCode>0</successCode>
                            <successCode>1</successCode>
                        </successCodes>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Tags: testid元素versionpluginexecexecutiongoals