Custom JUnit Report?

前端 未结 3 1402
名媛妹妹
名媛妹妹 2020-11-27 13:43

I am using the ant tasks \'junit\' and \'junitreport\' to run my JUnit Tests and generate a report at the end (=> \"Unit Test Results\").

Is it there some easy way t

3条回答
  •  伪装坚强ぢ
    2020-11-27 14:24

    The junitreport task uses XSLT to produce the report from the XML files generated by the junittask.

    You can customize the output by specifying your own XSLT using the styledir attribute of the nested report element:

    
    
    

    For customizing the the output, one option would be to make a copy of the default XSLT and modify that. Or you could look for an alternative XSLT which is more easy to customize for your purposes.

    For small changes, it might be easiest to just import the default XSLT and override whatever templates you need to customize. For example, to add a column for each test, you would need to override the template which produces the table header and the template which produces a table row. Below, I have just copied those templates and modified them a bit to add one column (look for two additions marked with ).

    
    
      
      
    
       
      
        
        
          
            Class
          
          Name
          Status
          Type
          Time(s)
    
          
          Screenshot
    
        
      
    
      
      
        
        
          
            
              Error
              Failure
              TableRowColor
            
          
          
            
          
          
            
          
          
            
            
              
                
              
              
                
              
            
          
          
            
              Failure
              
            
            
              Error
              
            
            
              Success
              
            
          
          
            
              
            
          
    
          
          
            screenshot
          
    
        
      
    
    
    

    Here's how the result looks like:

    screenshot

提交回复
热议问题