Allow the JUnit Provider to print relevant error logs when the test reference is wrong
(See https://project.squashtest.org/browse/SQUASH-4336 for the source if this issue.)
When the test reference doesn't target any class or method, the provider doesn't provide relevant logs that can help the user identify the error.
Currently in the provider, there are 3 2 problems:
1. By default, maven is encoded in UTF-16, which is not supported by the
2. The findstr
command used in the error_log Windows part;mvn test
step has no continue-on-error: True
, so whatever happens if this step goes wrong the error_log step won't be reached.
3. Maven returns an error when the test reference targets a non-existing class, however it doesn't when the test reference targets an existing class with a non-existing method name:
-
mvn test -Dtest=package.NonExistingClass
will return an error -
mvn test -Dtest=package.ExistingClass#nonExistingMethod
will run a test execution with 0 tests and succeed.
Therefore, there are 3 2 fixes to implement:
1. Document the need for the test repo POM file to specify the encoding Maven uses;
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<encoding>UTF-8</encoding>
<outputName>desired_name</outputName>
</configuration>
</plugin>
- Add a continue-on-error on the execute_action
mvn test
step; - Add a -DfailIfNoTests=true on both native and execute action
mvn test
steps.
(Edit: as highlighted by @lmazure down below the first point is irrelevant as Maven natively encodes its outputs in UTF-8 since 3.0.0-M1)