Powered By Blogger

Search Here!

Tuesday, August 28, 2012

Continuous Integration: Generate SpecFlow Report with append Time Stamp !

This Batch code calls the MSTest latest trx file and convert it into SpecFlow HTML report and save it with appending Time Stamp  and copy the HTML file in other driver for public access. This we majorly implemented and used in the CI that calls this batch file through MSBuild Definition and execute the Batch Commands.


set SAVESTAMP=%DATE:/=-%@%TIME::=-%
set SAVESTAMP=SMOKERESULT_%SAVESTAMP: =%.html

for /f "delims=" %%x in ('dir /od /a-d /b E:\B2\TestResults\*.*') do set recent=%%x    //Path of the directory where trx file resides.

echo %recent%

REM Remove space from the file name here

set OldFileName=%recent%

set NewFileName=%OldFileName: =%

ren "E:\B2\TestResults\%OldFileName%" %NewFileName%

"C:\Program Files\TechTalk\SpecFlow\SpecFlow.exe" mstestexecutionreport E:\B2\Sources\PegasusBDD\PegasusTestScripts\PegasusTestScripts.csproj /testResult:E:\B2\TestResults\%NewFileName% /out:%SAVESTAMP%

echo %SAVESTAMP%

copy %SAVESTAMP% Z:\

Saturday, August 11, 2012

Running MSTest and SpecFlow Report from Batch File !


It is very hectic setup the code in different machines by changing the aap.config any hardcoded path again and again. This is not the actual thing for coding and very unprofessional. Lets we have a lines of batch code that get rid from this, just run the batch commands in order to run the MSTest Metadata file containing Unit Test(s) and generates SpecFlow report.

Earlier it was something like, hard coded strings

if Exist "C:\Users\manish.singh\Desktop\Code 14th march\QA Automation\Pegasus_BDD\Framework.ReportGeneration\TestResult.trx" del "C:\Users\manish.singh\Desktop\Code 14th march\QA Automation\Pegasus_BDD\Framework.ReportGeneration\TestResult.trx"
"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /testcontainer:"C:\Users\manish.singh\Desktop\Code 14th march\QA Automation\Pegasus_BDD\Ordered_TestSuite\Pegasus_SpecFlow.OrderedTest.orderedtest" /resultsfile:"C:\Users\manish.singh\Desktop\Code 14th march\QA Automation\Pegasus_BDD\Framework.ReportGeneration\TestResult.trx"
"C:\Program Files\TechTalk\SpecFlow\SpecFlow.exe" mstestexecutionreport "C:\Users\manish.singh\Desktop\Code 14th march\QA Automation\Pegasus_BDD\PegasusTestScripts.csproj" /testresult:"C:\Users\manish.singh\Desktop\Code 14th march\QA Automation\Pegasus_BDD\Framework.ReportGeneration\TestResult.trx" /out:"C:\Users\manish.singh\Desktop\Code 14th march\QA Automation\Pegasus_BDD\Framework.ReportGeneration\MyResult.html"


Now change it into very generic fashion,


IF EXIST TestResult.trx DEL TestResult.trx

"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest"
/testmetadata:../STTestList.vsmdi /testlist:STTestList
/resultsfile:TestResult.trx

"C:\Program Files\TechTalk\SpecFlow\SpecFlow.exe" mstestexecutionreport
../PegasusTestScripts/PegasusTestScripts.csproj /testResult:TestResult.trx
/out:MyResult.html

echo Created file MyResult.html

MyResult.html