首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python & maven (单元测试集成)

python & maven (单元测试集成)
EN

Stack Overflow用户
提问于 2011-02-03 08:16:00
回答 4查看 13.9K关注 0票数 16

我有一个项目,主要是Java (使用maven作为构建工具),我们正在寻找添加一些python模块。将代码放在src/main/python中很容易,但是我还没有找到一个很好的方法来将maven的测试框架集成到我们的python单元测试中。有没有好的方法可以让我的java单元测试和python单元测试以相同的maven目标运行?(如果python单元测试的结果将显示在站点报告中,则会加分)。

EN

回答 4

Stack Overflow用户

发布于 2011-02-03 10:34:27

这似乎就是你要找的。还有一些其他地方在讨论这个问题。

http://steveberczuk.blogspot.com/2009/12/continuous-integration-of-python-code.html

http://www.mojohaus.org/exec-maven-plugin/

票数 5
EN

Stack Overflow用户

发布于 2020-07-22 00:17:04

http://steveberczuk.blogspot.com/2009/12/continuous-integration-of-python-code.html启发(正如@S.Lott所指出的),下面是一个有效的示例:

代码语言:javascript
复制
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
                <execution>
                    <id>python-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>python3</executable>
                        <workingDirectory>${project.build.directory}</workingDirectory>
                        <arguments>
                            <argument>-m</argument>
                            <argument>unittest</argument>
                            <argument>discover</argument>
                            <argument>.</argument>
                        </arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>

在这种情况下,我们的测试是在${project.build.directory}上进行的,并且构建机器上安装了python3

票数 1
EN

Stack Overflow用户

发布于 2013-04-26 15:20:51

您还可以研究一下http://mavenjython.sourceforge.net/test/。尽管如此,Jython可能不支持在Python代码中使用的内容。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4881482

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档