开发者

TRX output file not appearing

I'm developing an automated unit test framework for C#. My task is to find all the .bat files in one directory, execute 开发者_运维问答them all, and then read the .trx output through the command line as of now.

The problem I'm facing is, when I manually execute the .bat files in file explorer, the .trx files are appearing. But when I try to execute the .bat files through a program, the .trx files do not appear, even though the bat files are successfully running, which means my program can't track them and no output is being written out. Can someone point out where I'm making a mistake? Thank you!

// Find all files with the .bat extension in the current directory
        string pathBat = @"C:\Users\lokesshpathmanatan\Downloads\MSTestSample";
        string[] bat_files = Directory.GetFiles(pathBat, "*.bat");

        foreach (string bat_file in bat_files)
        {
            // Start the .bat file as a new process
            Process process = Process.Start(bat_file);

            // Check if the process has finished running
            while (!process.HasExited)
            {
                // Wait for the process to finish
                System.Threading.Thread.Sleep(500);
            }

            // The process has finished running
            Console.WriteLine($"{bat_file} has finished testing.");
        }

        // Find all files with the .trx extension in the current directory
        string pathTrx = @"C:\Users\lokesshpathmanatan\Downloads\MSTestSample\TestResults";
        string[] trx_files = Directory.GetFiles(pathTrx, "*.trx", SearchOption.AllDirectories);

        // Filter the files to only include those that were modified at / after the current time
        string[] newer_trx_files = trx_files.Where(file => File.GetLastWriteTime(file) >= current_time).ToArray();

TRX output file not appearing

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜