Using:
Selenium, TestNG, Java and Python
So, I run my TestNG tests and these result in some cool looking results automatically (win). These look a bit like this:
Two limitations though:
- I want everyone to be able to view this easily, and
- I want a historical record of past runs to be present
Solution, I'm saving these in to a folder which is hosted up by a simple HTTP server, which is built in to Python.
Python / simple HTTP server
Go to directory.
Invoke the following:
c:\dev\opt\python-2.7\python -m SimpleHTTPServer 8000
Obviously I've put in the path to Python, obviously you'll need to change the path to wherever your Python is.
Historical Record
This was achieved by just creating a copy of the assets at the location being served up whenever I wanted.
By navigating to the root dir in a browser I could see all of my result folders.
Nice, now I just click on a link.
Batch Scripting a folder copy for historical run results
Just because I am too lazy to copy a folder and rename the new one to a date stamp I created the following batch script which would do it for me.
@echo off
ECHO Generating timestamp to use in folder name
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%b%%a)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
echo %mydate%-%mytime%
SET newResultFolderName=%mydate%-%mytime%
ECHO New folder name will be %newResultFolderName%
SET locationOfLatestRunResults="C:\dev\tests\DrivingXml\test-output\"
SET uriToPublishResults="\\myserver01\selenium-test-output\welc\%newResultFolderName%\"
ECHO Location of latest run results: %locationOfLatestRunResults%
ECHO URI to publish results to: %uriToPublishResults%
XCOPY /S /V /Z %locationOfLatestRunResults%* %uriToPublishResults%
EXPLORER %uriToPublishResults%
No comments:
Post a Comment