Ask a Question

Custom HTML reports - Need Your Contribution

Lucian
Community Hero

Custom HTML reports - Need Your Contribution

Hi guys,

 

I am working on a custom HTML report for ReadyApi tests. This is how the report will look like:

 

2018-10-01_16h43_12.png

If you know html, css, javascript or groovy and you want to contribute the git project can be found here.



If my answer helped please click on the 'Accept as Solution' button.
37 REPLIES 37
Lucian
Community Hero

Just commited the latest code. 

 

If you open the project in \ReadyAPI\Reporting you should be able to see the code that I created so far (in the project tear down script).

 

The problem is the api is cumbersome as ReadyApi uses both the old SoapUI api and the new one so it's difficult for me to create the report. Still WIP.



If my answer helped please click on the 'Accept as Solution' button.
Olga_T
SmartBear Alumni (Retired)

Thank you for the update, @Lucian!

 

Maybe, is there any specific task we could ask the Community to accomplish to complete the report?

 


Olga Terentieva
SmartBear Assistant Community Manager

Lucian
Community Hero

I have the following code:

 

if ( it.getClass() == com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequestStep ) {
				reportFile.text = '''<!DOCTYPE html><html><head><style>html,body{margin:0;padding:0;}html{height:100%;}body{height:98%;}h1{font-size:20px;}h2{font-size:16px;}.column{float:left;border:solid gray 1px;height:90%;margin-left:4px;padding:5px;}.assertion_container{margin:4px;background-color:white;border:solid gray 1px;width:95%;padding:4px;}.assertion_details{margin-left:60px;}#content_wrapper{width:100%;height:60%;}#request{background-color:#F0F0F0;width:48%;height:100%;overflow:auto;}#response{background-color:#F0F0F0;width:48%;height:100%;overflow:auto;}#assertions_wrapper_container{background-color:#F0F0F0;float:left;margin-top:4px;margin-left:4px;padding:5px;border:solid gray 1px;height:30%;width:97%;overflow:scroll;}</style></head><body>
	    							 <h1>''' + it.getName() + '''</h1><div id="content_wrapper"><div id="request" class="column"><div id="request_title"><h2>Request</h2></div><div id="request_content"><pre>''' +
	    							 new String(it.getTestStep().testRequest.messageExchange.rawRequestData) + '''</pre></div></div><div id="response" class="column"><div id="response_title"><h2>Response</h2></div><div id="response_content"><pre>''' +
								 new String(it.getTestStep().testRequest.messageExchange.rawResponseData) + '''</pre></div></div></div><div id="assertions_wrapper_container"><div id="assertions_title"><h2>Assertions</h2></div>'''
	     		if ( it.getAssertionList().size()  == 0 ) {
	     			reportFile << '''<div><i>There are no assertions in this test step<i></div>'''
	     		}
	     		else {
					it.getAssertionList().each() {
						reportFile <<  '''<div class="assertion_container"><div class="assertion_name"'''
						if ( it.getStatus().toString() == "PASS" ) {
							reportFile << ''' style="color:green"'''
						} else if ( it.getStatus().toString() == "FAIL" ) {
							reportFile << ''' style="color:red"'''
						}
						reportFile << '''><b>''' + it.getStatus() + '''</b> - ''' + it.getName() + '''</div>'''
						if (it.getErrors())
							reportFile << '''<div class="assertion_details"><t/><i>''' + it.getErrors()[0].getMessage() + '''</i></div>'''
						reportFile << '''</div>'''
			     	}
				}
				reportFile << '''</div></body></html>'''	
			} else if ( it.getClass() == com.eviware.soapui.impl.wsdl.teststeps.DebuggableWsdlGroovyScriptTestStep ) {
				reportFile.text = '''<!DOCTYPE html><html><head><style>html,body{margin:0;padding:0;}html{height:100%;}body{height:98%;}h1{font-size:20px;}h2{font-size:16px;}#script{background-color:#F0F0F0;width:97%;height:60%;overflow:scroll;border:solid gray 1px;padding:4px}#log_container{margin-top:4px;background-color:#F0F0F0;border:solid gray 1px;width:97%;height:30%;padding:4px;}</style></head><body><h1>TestStep2 from TestCaseA from TestSuiteA</h1><div id="script">''' +
                                      '''<h2>Script content</h2><pre>''' + it.scriptText + '''</pre></div><div id="log_container"><h2>Script log</h2>The script log is not yet available @TODO</div></body></html>'''
			}

I am iterating through each step. If the step is of type HTTP step then the report is already done. I am trying now to do the same for Soap steps.



If my answer helped please click on the 'Accept as Solution' button.
Olga_T
SmartBear Alumni (Retired)

Community, any ideas on how to modify this code so that it could work for Soap steps?

 


Olga Terentieva
SmartBear Assistant Community Manager

Radford
Super Contributor

Hi @Lucian,

 

I was looking at your code, and if you don't mind may I make a sugestion? Rather than handling each type of step independently, when you loop through the steps have you considered checking to see if they implement an interface and then handle that for all steps? For example I see you get the assetion details for the HttpTestRequestStep, but you could check to see if the step implements the Assertable interface and if so then process with common code regardless of type.

 

You can use the "in" keyword to check to to see if an object implements an interface, the following post is an example where I have done this:

 

https://community.smartbear.com/t5/SoapUI-Pro/how-to-find-teststep-disabled-or-enabled/m-p/166149/hi...

 

 

Sorry for the late response, @Radford. Your suggestion is good. This was actually my starting point.

 

However, either I'm missing it or there is no common interface for all type of requests. From what I can see ReadyApi uses both new methods (from the premium product) and old methods (from the free version of SoapUI) which makes it difficult for me to work with it.



If my answer helped please click on the 'Accept as Solution' button.

@Lucian

i tried for once for generating pdf report using external jar.

a) write the code in eclipse.

b) export the code as jar.

c) put this in ext folder

d) restart the soapui.

e) import the related pkg. for your utility.

f) call the method to generate report.

 

it works for me hope the same for you.

please accept as solution if it works.

 

TanyaYatskovska
SmartBear Alumni (Retired)

Hi Ashu248,

Thanks for your contribution! @Lucian, are there more features to do in this project?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



Reporting gives the visual experience and whatever change made will still feel like something missing or could be done little more.

I use Junit report using "apache ant" and happy about it while still gives the granual details. Also most widely used in development world.

Good that Lucian had tried something new as per his requirements and thank for sharing the artefacts. Hope that helps people for those who want get it for use or start with it to make changes if more requirements.


Regards,
Rao.

@nmrao

currently i am using extent report for custom reporting purpose in soapui that also provides good visual experience and feel like other automation tool reporting. 

 

"you like the idea ? Give Kudos " Smiley HappySmiley Happy

 

cancel
Showing results for 
Search instead for 
Did you mean: