Powered By Blogger

Search Here!

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

No comments:

Post a Comment