I'm building a test execution system based on Gallio to do some internal, scheduled testing. I've got a Windows service that periodically monitors a DB table. When if finds work to do, as determined by a new record in the table, it adds a method call to a ThreadPool that wraps the following code:
public static TestLauncherResult RunTests(List<string> testSuites, List<string> testMethods, List<string> testFilePatterns, string testResultsDir)
{
GallioRuntimeLoader.InitializeRuntime();
TestLauncher.Logger = new TextLogger(new StreamWriter(new FileStream(@"c:\logroot\GallioTestLauncher.log", FileMode.Append)));
TestLauncher.EchoResults = true;
foreach (string s in testFilePatterns)
{
TestLauncher.AddFilePattern(s);
}
Log.Info(string.Format("Test file patterns for test run: {0}", String.Join("|", testFilePatterns)));
var filters = testSuites.Select(s => FilterUtils.ParseTestFilter("Type: " + s)).ToList();
filters.AddRange(testMethods.Select(m => FilterUtils.ParseTestFilter("Member: " + m)));
Log.Info(string.Format("Filters for test run: {0}", String.Join("|", filters)));
TestLauncher.TestExecutionOptions.FilterSet = new FilterSet<ITestDescriptor>(new OrFilter<ITestDescriptor>(filters));
TestLauncherResult result = null;
try
{
Log.Debug("Calling TestLauncher.Run();");
result = TestLauncher.Run();
Log.Debug(string.Format("TestLauncher.Run() returned: {0}", result.ResultSummary));
}
catch (Exception e)
{
Log.Error(string.Format("Exception caught when executing the tests: {0}", e.Message));
throw;
}
var reportFormats = new List<string>();
reportFormats.Add("html");
string reportName = string.Format("{0:M-d-yyyy_HH_mm_ss}", DateTime.Now);
var reportFormatOptions = new ReportFormatterOptions();
IProgressMonitor progressMonitor = NullProgressMonitor.CreateInstance();
if (result != null)
{
result.GenerateReports(testResultsDir, reportName,
ReportArchive.Normal, reportFormats, reportFormatOptions,
RuntimeAccessor.ServiceLocator.Resolve<IReportManager>(), NullProgressMonitor.CreateInstance());
}// if (result != null)
return result;
}// public static TestLauncherResult RunTests(List<string> testSuites, List<string> testMethods, List<string> testFilePatterns, string testResultsDir)
This code works perfectly when I run it on my dev box. It runs whatever test suites and/or methods I pass into it, and generates the appropriate reports.
However, I'm seeing some odd behavior when I run it on our test server. Here's a description of the odd-ness:
"C:\Program Files\Gallio\bin\Gallio.Host.exe" /ipc-port:IsolatedProcessHost.89518a08f802b1af /timeout:120 /owner-process:4984 /application-base-directory:"C:\src\_Release_Branches\qa_automation\qa_automation\Apps\Services\TAAG.SchedulingService\bin\Debug" /configuration-file:"C:\src\_Release_Branches\qa_automation\qa_automation\Apps\Services\TAAG.SchedulingService\bin\Debug\fd4fe11402563b66.tmp.config" /severity-prefix
I've tried to attach my debugger to Gallio.Host hoping to catch an exception, but I am always too late.
1. What would cause this not to work on some servers, but work perfectly on my Dev box?
2. How can I invoke Gallio.Host via the TestLauncher object such that the debug statements will print in my Gallio logger object?
3. Am I better off constructing a call to Gallio.Echo.exe and capturing the result of that program?