How to get Maven to print test names that failed?

I am using Maven 3.0.3, JUnit 4.8.1 and Spring 3.1.1.RELEASE. I have a Surefire plugin configured this way.

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.14.1</version> <configuration> <reuseForks>false</reuseForks> <argLine>-Xmx2048m -XX:MaxPermSize=512M</argLine> </configuration> </plugin> 

I notice that when my unit tests fail due to IllegalStateExceptions, Maven never prints out the names of tests that were not executed at the end of execution. I will see instead

 mvn clean install ... Tests in error: ? IllegalState Failed to load ApplicationContext ? IllegalState Failed to load ApplicationContext ? IllegalState Failed to load ApplicationContext ? IllegalState Failed to load ApplicationContext 

How can I get Mavne to print more details about testing errors? Right now I need to break through the directory of correct reports to find out what failed. Most of my JUnit tests look like this:

 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "classpath:test-context.xml" }) public class CleverTeacherServiceTest extends AbstractImportServiceTest { 
+4
source share
1 answer

I think your test Spring configurator does not work before running your tests. Usually you should see the failed tests listed in the console, for example:


TESTS

Launching TestSuite .. Spaces: 234, Errors: 1, Errors: 0, Missed: 0, Elapsed Time: 7.019 seconds. <FAILURE! fooTest (BarTest) Elapsed time: 0.011 s <FAILURE! fooTest (BarTest.java:23)

Results:

Failed tests: BarTest.fooTest: 23 null

Running tests: 234, Errors: 1, Errors: 0, Missed: 0

You can run your tests by setting the plugf property of the correct fryfire useFile == false so that all plug-in output is sent to the console. I would not configure this in the pom file, but run it like this:

mvn -Dsurefire.useFile=false clean test

For configuration information, see Surefire Plugin docs .

+1
source

Source: https://habr.com/ru/post/1491666/


All Articles