Forum Discussion

prajakta's avatar
prajakta
Occasional Contributor
5 years ago
Solved

readyapi report

how to creare ready API report in that Requirement - 1)testsuite name 2)teatcase name 3)test step name 4)request response for pass and fail test steps 5)method 6)Statuscode All are required ...
  • nmrao's avatar
    5 years ago
    Not a clear question.
    What type of report are you looking? junit, pdf or something else?
  • prajakta's avatar
    prajakta
    5 years ago

    nmrao wrote:
    Not a clear question.
    What type of report are you looking? junit, pdf or something else

     

    please find attached image.


     

  • prajakta's avatar
    prajakta
    5 years ago

    Pdf type report needed

    Also shows pass test case - green color and fail  test case - red

    below code is not sufficient for that plaese help in that

    // Below code goes in set up script tab
    
    FileWriter file = new FileWriter("D:/udm/reporting/Report.html")
    def str = '''<HTML>
    	<HEAD>
    		<meta charset='UTF-8'>
    			<title>WEBSERVICE TEST AUTOMATION REPORT</title>
    			<style>
    				.demo {
    					border:1px solid #C0C0C0;
    					border-collapse:collapse;
    					padding:5px;
    				}
    				.demo th{
    					border:1px solid #C0C0C0;
    					padding:5px;
    					background:#E0F0F1;
    				}
    				.demo td{
    					border:1px solid #C0C0C0;
    					padding:5px;
    					background:white;
    				}
    			</style>
    	</Head>
    	
    	<table class="demo">
    		<h3> WEBSERVICE TEST AUTOMATION REPORT</h3>
    			<thead>
    				<tr>
    					<th>Test Step</th>
    					<th>Method</th>
    					<th>Status Code</th>
    					<th>Endpoint</th>
    				</tr>
    			</thead>
    			
    			<tbody>'''
    file.write(str)
    file.close()
    
    
    // Below code goes in TearDown script tab
    
    FileWriter file = new FileWriter("D:/udm/reporting/Report.html", true)
    def testStepName
    def method
    def statusCode
    def endpointURL
    def str
    
    testCase.testStepList.each{
    	testStepName = it.name
    	method = it.getHttpRequest().getResponse().getMethod()
    	statusCode = it.testRequest.response.responseHeaders["#status#"][0]
    	endpointURL  = it.getHttpRequest().getResponse().getURL()
    
    	str = "<tr><td>${testStepName}</td><td>${method}</td><td>${statusCode}</td><td>${endpointURL}</td></tr>"
    	file.append(str)
    }
    
    file.append("</tbody></table></HTML>")
    file.close()

    color