Im running a process (c#, .NET8. xUnit) that creates a test environment (downloading tests, downloading and running applications needed for the tests etc).
When the env is ready the process runs this code:
var args = BuildArguments(testPath, testsResultsPath, clientAppPids, _config.GithubBranchName);
Console.WriteLine($"Running tests with arguments: {args}");
var testsProcess = _processManager.RunProcess(true, "dotnet", args);
var testCts = new CancellationTokenSource(_config.TestTimeoutMs);
await testsProcess.WaitForExitAsync(testCts.Token);
The RunProcess
func is implemented like so:
public IProcessWrapper RunProcess(bool redirectOutput, string command, string arguments)
{
try
{
_logger.SafeLog($"Running process: {command} {arguments}");
var processStartInfo = new ProcessStartInfo
{
FileName = command,
Arguments = arguments,
RedirectStandardOutput = redirectOutput,
RedirectStandardError = redirectOutput,
UseShellExecute = false,
CreateNoWindow = true
};
var process = new Process
{
StartInfo = processStartInfo
};
process.Start();
return new ProcessWrapper(process);
}
catch (Exception e)
{
_logger.SafeLogException($"RunProcess failed: {command} {arguments}", e);
throw;
}
}
this code runs the tests like so:
dotnet test C:WindowsTempMyTests.dll --logger:"junit;LogFileName=C:WindowsTempMy_FolderTestResultstest_res.xml" --verbosity normal --filter "test_name=my-test" --environment DATA_NEEDED_FOR_TEST=some-data --environment BRANCH_NAME=some-name
Once the tests are finished (successfully, failed or timeout) I expect the test logs file to appear. However – my problem is that it does not appear (only in windows, in linux it seems to work fine). It finally appears when the parent process of the test is finished and exists. I looked here and on the net for anything but with no success. I suspect it has something to do with flushing the process somehow, or because i redirect the output, or something to do with disposing the ITestOutputHeler (xunit logger) – but didnt make any progress. would appreciate any help.
2