I was able to generate the unit test result(.trx) file with the help of below link :
Saving unit test results after running tests
Apart from using cmd to generate the .trx file, is there any way to generate the same via code itself.
Thanks in advance.
EDIT
Below is the my sample code :
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo myStartInfo = new System.Diagnostics.ProcessStartInfo();
myStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
myStartInfo.UseShellExecute = false;
myStartInfo.FileName = "cmd.exe";
myStartInfo.Verb = "runas";
myStartInfo.WorkingDirectory = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow";
myStartInfo.Arguments = @"/C VSTest.console C:\UnitTestProject1\UnitTestProject1\bin\Debug\UnitTestProject1.dll /logger:trx";
process.StartInfo = myStartInfo;
process.Start();
Please note that cmd needs to be run as admin.