[Webtest] Change to display test file name and line in reports

Marc Guillemot webtest@lists.canoo.com
Fri, 26 Sep 2003 08:52:20 +0200


This is a multi-part message in MIME format.
--------------080609070104090403010107
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

attached is a patch to generate the exact location of the <testSpec> tag in the 
xml report. The small change I proposed previously required less changes but was 
not precise enough, particularly in the case where the first step is included 
using an entity.

<testresult
   endtime="Thu Sep 25 15:59:45 CEST 2003"
 
location="file:/home/marc/EWorkspace/junetz/web-app/WEB-INF/src/webtests/front/testMainpage.xml:12: 
"
   starttime="Thu Sep 25 15:58:50 CEST 2003"
   successful="yes" testspecname="front mainpage links">



This additional attribute in the testResults.xml needs to be transformed by the 
xslt. Perhaps would it be interesting to provide more than one xslt. The user 
could choose which one they want to adapt for their own reports. For instance 
mine (still evolving), adapted from the Canoo original version that existed a 
few months ago, now generates a global report summary and a separated report 
page for each test. This was necessary, as the size of the file growed too fast 
with the number of webtests.


Mittie, is it possible to have a commiter access?

Marc.


Dierk Koenig wrote:
> Hi Marc,
> 
> thanx for the contribution.
> 
> The file reference is currently only reported in the error case.
> I agree that it is also usefull for the general case.
> 
> cheers
> Mittie
> 
> 
>>-----Original Message-----
>>From: webtest-admin@lists.canoo.com
>>[mailto:webtest-admin@lists.canoo.com]On Behalf Of Marc Guillemot
>>Sent: Mittwoch, 24. September 2003 17:35
>>To: webtest@gate.canoo.com
>>Subject: [Webtest] Change to display test file name and line in reports
>>
>>
>>I'm missing in the test reports an indication of the location of 
>>the test script 
>>(which file at which line). I think this is really usefull when 
>>the number of 
>>tests increases.
>>I've performed a small change in
>>com.canoo.webtest.reporting.addResultAttributes(Element resultElement)
>>(line 179 in build 365)
>>
>>Before:
>>--------
>>List steps = 
>>fResult.getContext().getTestSpecification().getUserTestSteps();
>>addNewAttribute(resultElement, "starttime", ((Step) 
>>steps.get(0)).getStarted().toString());
>>--------
>>
>>after
>>--------
>>List steps = 
>>fResult.getContext().getTestSpecification().getUserTestSteps();
>>Step firstStep = (Step) steps.get(0);
>>addNewAttribute(resultElement, "location", 
>>firstStep.getLocation().toString());
>>addNewAttribute(resultElement, "starttime", 
>>firstStep.getStarted().toString());
>>--------
>>
>>this allows to have in the xml file something like:
>>
>><testresult
>>   endtime="Wed Sep 24 16:51:57 CEST 2003"
>>location="file:/home/marc/EWorkspace/junetz/web-app/WEB-INF/src/we
>>btests/admin/accessLoginPage.def.xml:29: 
>>"
>>         starttime="Wed Sep 24 16:51:51 CEST 2003"
>>         successful="yes" testspecname="add contact to institution">
>>
>>This is not exactly the location of the <testSpec> opening tag as 
>>it seems it 
>>would need more changes to the current code, but it allows 
>>already to get an 
>>information on the location that can be formatted by the xslt.
>>
>>Marc.
>>
>>_______________________________________________
>>WebTest mailing list
>>WebTest@lists.canoo.com
>>http://lists.canoo.com/mailman/listinfo/webtest
>>
>>
> 
> 
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> 


--------------080609070104090403010107
Content-Type: text/plain;
 name="addTestLocationPatch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="addTestLocationPatch.txt"

Index: canoo/webtest/ant/TestSpecificationTask.java
===================================================================
RCS file: /repositories/cvs/public/webtest/src/com/canoo/webtest/ant/TestSpecificationTask.java,v
retrieving revision 1.27
diff -r1.27 TestSpecificationTask.java
72a73
> 		webTestResult.setSourceLocation(getLocation());
Index: canoo/webtest/engine/ResultInfo.java
===================================================================
RCS file: /repositories/cvs/public/webtest/src/com/canoo/webtest/engine/ResultInfo.java,v
retrieving revision 1.2
diff -r1.2 ResultInfo.java
2a3,4
> import org.apache.tools.ant.Location;
> 
12a15
> 	private Location sourceLocation_ = Location.UNKNOWN_LOCATION;
62a66,82
> 
> 	/**
> 	 * Gets the location of the source of the test script 
> 	 */
> 	public Location getSourceLocation()
> 	{
> 		return sourceLocation_;
> 	}
> 
> 	/**
> 	 * Sets the location of the source of the test script 
> 	 */
> 	public void setSourceLocation(Location _location)
> 	{
> 		sourceLocation_ = _location;
> 	}
> 
Index: canoo/webtest/reporting/XmlResultConverter.java
===================================================================
RCS file: /repositories/cvs/public/webtest/src/com/canoo/webtest/reporting/XmlResultConverter.java,v
retrieving revision 1.14
diff -r1.14 XmlResultConverter.java
176a177
> 		addNewAttribute(resultElement, "location", fResult.getSourceLocation().toString());

--------------080609070104090403010107--