static int Main(string[] args) { System.Console.WriteLine("Loading test suite..."); // Load static container of all tests. List <TestEnvironment> listEnvironments = new List <TestEnvironment>(); TestEnvironments.AddAll(listEnvironments); int testIndex = 1; foreach (TestEnvironment environment in listEnvironments) { string message = string.Format("{5} - Running test {3} / {4} - {0} on {1} (Snapshot: {2})", environment.Description, environment.OperatingSystem, environment.SnapshotName, testIndex, listEnvironments.Count, DateTime.Now); System.Console.WriteLine(message); TestRunner runner = new TestRunner(true, environment, true); runner.TestCompleted += new TestRunner.TestCompletedDelegate(runner_TestCompleted); if (!runner.Run()) { return(-1); } testIndex++; } return(0); }
private void formConfigurations_Load(object sender, EventArgs e) { if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1) { MessageBox.Show("Only one instance of this application can be started.", "VMwareIntegration", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } try { List <TestEnvironment> listEnvironments = new List <TestEnvironment>(); TestEnvironments.AddAll(listEnvironments); foreach (TestEnvironment environment in listEnvironments) { ListViewItem item = listConfigurations.Items.Add(environment.Description); item.SubItems.Add(environment.OperatingSystem); item.SubItems.Add(environment.DatabaseType); item.SubItems.Add(environment.SnapshotName); item.SubItems.Add(""); // Status item.Tag = environment; item.Checked = true; } } catch (Exception ex) { MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace, "VMwareIntegration", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
static int Main(string[] args) { var softwareUnderTest = args[0]; _logFile = string.Format("{0}-{1}.log", softwareUnderTest, DateTime.Now.ToString("yyyy-MM-dd HHmmss")); if (!File.Exists(softwareUnderTest)) { LogText(string.Format("The file {0} does not exist.", softwareUnderTest)); return(-1); } LogText("Loading test suite..."); // Load static container of all tests. List <TestEnvironment> listEnvironments = new List <TestEnvironment>(); TestEnvironments.AddAll(listEnvironments); int testIndex = 0; var f = TaskScheduler.Default; var options = new ParallelOptions() { MaxDegreeOfParallelism = 4, }; // We can run tests on XP and Vista/2003/2008 at the same time since it's separate VMware images. var environmentsGroupedByVmwareImage = listEnvironments.GroupBy(item => item.VMwarePath).ToList(); var partitioner = Partitioner.Create(environmentsGroupedByVmwareImage, EnumerablePartitionerOptions.NoBuffering); Parallel.ForEach(partitioner, options, environmentGroup => { foreach (var environment in environmentGroup) { int localIndex; lock (_lockCounterTest) { localIndex = ++testIndex; string message = string.Format("{0}: {1}/{2} - Test: {3} on {4} with db {5}. Image: {6} (Snapshot: {7})", DateTime.Now, localIndex, listEnvironments.Count, environment.Description, environment.OperatingSystem, environment.DatabaseType, Path.GetFileName(environment.VMwarePath), environment.SnapshotName); LogText(message); } var runner = new TestRunner(true, environment, false, softwareUnderTest); try { runner.Run(); LogText(string.Format("{0}: Test {1} completed successfully.", DateTime.Now, localIndex)); } catch (Exception ex) { LogText(string.Format("{0}: Test {1} failed.", DateTime.Now, localIndex)); LogText(ex.ToString()); throw; } } }); System.Console.WriteLine("All tests completed succesfully."); if (System.Diagnostics.Debugger.IsAttached) { System.Console.WriteLine("Press Enter to exit."); System.Console.ReadLine(); } return(0); }
static int Main(string[] args) { var softwareUnderTest = args[0]; _logFile = args[1]; _logFile = _logFile.Replace("%TIMESTAMP%", DateTime.Now.ToString("yyyy-MM-dd HHmmss")); if (!File.Exists(softwareUnderTest)) { LogText(string.Format("The file {0} does not exist.", softwareUnderTest)); return(-1); } if (softwareUnderTest.Equals(_logFile, StringComparison.InvariantCultureIgnoreCase)) { LogText("Software under test cannot be same as log file."); return(-1); } LogText("Loading test suite..."); // Load static container of all tests. List <TestEnvironment> listEnvironments = new List <TestEnvironment>(); TestEnvironments.AddAll(listEnvironments); int testIndex = 0; int failedTests = 0; var options = new ParallelOptions() { MaxDegreeOfParallelism = 8, }; // We can run tests on XP and Vista/2003/2008 at the same time since it's separate VMware images. var environmentsGroupedByVmwareImage = listEnvironments.GroupBy(item => item.VMwarePath).ToList(); var partitioner = Partitioner.Create(environmentsGroupedByVmwareImage, EnumerablePartitionerOptions.NoBuffering); Parallel.ForEach(partitioner, options, environmentGroup => { foreach (var environment in environmentGroup) { int localIndex; lock (_lockCounterTest) { localIndex = ++testIndex; string message = string.Format("{0}: {1}/{2} - Test: {3} on {4} with db {5}. Image: {6} (Snapshot: {7})", DateTime.Now, localIndex, listEnvironments.Count, environment.Description, environment.OperatingSystem, environment.DatabaseType, Path.GetFileName(environment.VMwarePath), environment.SnapshotName); LogText(message); } var runner = new TestRunner(true, environment, false, softwareUnderTest); try { runner.Run(); LogText(string.Format("{0}: Test {1} completed successfully.", DateTime.Now, localIndex)); } catch (Exception ex) { LogText(string.Format("{0}: Test {1} failed.", DateTime.Now, localIndex)); LogText(ex.ToString()); lock (_lockCounterTest) { failedTests++; } } } }); if (failedTests == 0) { System.Console.WriteLine("All tests suites completed succesfully. Press Enter to exit."); } else { System.Console.WriteLine(string.Format("{0} tests suites failed. Press Enter to exit.", failedTests)); } System.Console.ReadLine(); return(0); }