How to identify slow unit tests when using maven-surefire-plugin in parallel mode?

后端 未结 1 1826
广开言路
广开言路 2021-01-04 09:36

With a view to managing / reducing our build times, I want to identify which unit tests are taking the most time - in a parallel test environment using the maven-suref

1条回答
  •  情书的邮戳
    2021-01-04 10:15

    Adding to the Maven Surefire Plugin configuration the reportFormat entry and setting its value to plain (instead of the default brief) would give you elapsed time per method.

    
        
            
                org.apache.maven.plugins
                maven-surefire-plugin
                2.19
                
                    -Xmx2G -XX:MaxPermSize=1G -XX:-UseSplitVerifier
                    false
                    classesAndMethods
                    true
                    plain
                
            
        
    
    

    Output with default reportFormat (brief):

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running com.sample.mocking.InternalServiceTestCase
    Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.241 sec - in com.sample.mocking.InternalServiceTestCase
    

    Output with plain value:

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running com.sample.mocking.InternalServiceTestCase
    Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.187 sec - in com.sample.mocking.InternalServiceTestCase
    test(com.sample.mocking.InternalServiceTestCase)  Time elapsed: 0.005 sec
    mockTest(com.sample.mocking.InternalServiceTestCase)  Time elapsed: 0.17 sec
    mockTestFailureTollerance(com.sample.mocking.InternalServiceTestCase)  Time elapsed: 0.007 sec
    mockProcessfile(com.sample.mocking.InternalServiceTestCase)  Time elapsed: 0.003 sec
    

    This option may give you further details on tests and execution time.

    0 讨论(0)
提交回复
热议问题