I am trying to configure my maven build so that mvn test runs my python tests in addition to my java tests. I am 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.pyWhen I try to run it from the root of the project:
mvn exec:exec@python-testI get 0 tests executed:
---------------------------------------------------------------------- Ran 0 tests in 0.000s OKBut, 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.010sWhat am I doing wrong here?
Thanks in advance!
Turns out the single quotes on this line were the problem: <argument>'*_test.py'</argument> . The single quotes around the file -p "'*_test.py'" and did not match any files. Removing them fixed the problem.