I'm trying to set up my maven build so that mvn test
runs my python tests in addition to my Java tests. I'm trying to use the exec-maven-plugin
to do this.
My pom.xml
has:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<configuration>
<executable>python3</executable>
<workingDirectory>${project.basedir}/src/main/resources/scripts/</workingDirectory>
<arguments>
<argument>-m</argument>
<argument>unittest</argument>
<argument>discover</argument>
<argument>-p</argument>
<argument>'*_test.py'</argument>
</arguments>
</configuration>
<id>python-test</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
My project structure is like:
.
├── pom.xml
├── src
│ ├── main
│ │ └── resources
│ │ ├── scripts
│ │ │ ├── __init__.py
│ │ │ ├── foo.py
│ │ │ ├── foo_test.py
When I try to run it from the project root:
mvn exec:exec@python-test
I get 0 tests ran:
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
But, if I do this manually, it works fine:
cd src/main/resources/scripts
python3 -m unittest discover -p '*_test.py'
...
----------------------------------------------------------------------
Ran 3 tests in 0.010s
What am I doing wrong here?
Thanks in advance!
from Running "python -m unittest" failing with maven exec-maven-plugin
No comments:
Post a Comment