Christian Seiler
Christian Seiler

Reputation: 1140

JUnit 5 Console does not find tests

I am using JUnit5 Console in my Ant build script. However it does not find any tests in my project.

I've used the following command in Terminal:

-jar lib\junit-platform-console-standalone-1.1.0-RC1.jar --class-path bin --scan-class-path

which returns:

[36m.[0m
[36m+--[0m [36mJUnit Jupiter[0m [32m[OK][0m
[36m'--[0m [36mJUnit Vintage[0m [32m[OK][0m

Test run finished after 27 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]

I get the same output for the Ant script:

<target name="test" depends="compile" description="Runs JUnit Tests">
    <java jar="lib\junit-platform-console-standalone-1.1.0-RC1.jar" fork="true">
        <arg value="d ."/>
        <arg value="-details verbose"/>
    </java>
</target>

Upvotes: 2

Views: 2850

Answers (2)

Christian Seiler
Christian Seiler

Reputation: 1140

I fixed it: The Arguments have to be lines:

<target name="test" depends="test-javac" description="Runs JUnit Tests">
    <java jar="${junit.jar}" fork="true">

        <arg line="--class-path bin"/>
        <arg line="--scan-class-path"/>
        <arg line="--reports-dir reports"/>

        <!-- Available options: [ascii,unicode]-->
        <arg line="details-theme unicode"/>

        <!-- Available options: [none,flat,tree,verbose]-->
        <arg line="--details tree"/>
    </java>
</target>

Upvotes: 1

Sormuras
Sormuras

Reputation: 9059

You need to specify where the launcher can find your compiled test classes. See https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher for details.

How are your test classes named? Are they stored by "javac" directly under "bin/"?

Maybe the answer and comments posted here Unable to run tests with JUnit5 Console Launcher are helpful.

Upvotes: 0

Related Questions