Run() public method

public Run ( ) : bool
return bool
Exemplo n.º 1
0
        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 += runner_TestCompleted;
            if (!runner.Run())
               return -1;

            testIndex++;
             }

             return 0;
        }
Exemplo n.º 2
0
        static int Main(string[] args)
        {
            var softwareUnderTest = args[0];
             _logFile = args[1];
             _logFile = _logFile.Replace("%TIMESTAMP%", DateTime.Now.ToString("yyyy-MM-dd HHmmss"));

             LogText("Loading test suite...");

             // Load static container of all tests.
             List<TestEnvironment> listEnvironments = new List<TestEnvironment>();
             TestEnvironments.AddAll(listEnvironments);

             int testIndex = 0;

             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);

             Parallel.ForEach(environmentsGroupedByVmwareImage, options, environmentGroup =>
             {
            foreach (var environment in environmentGroup)
            {
               int localIndex = Interlocked.Increment(ref testIndex);

               string message = string.Format("{5} - Running test {3} / {4} - {0} on {1} (Snapshot: {2})",
                  environment.Description,
                  environment.OperatingSystem,
                  environment.SnapshotName,
                  localIndex,
                  listEnvironments.Count,
                  DateTime.Now);

               LogText(message);

               TestRunner runner = new TestRunner(true, localIndex, environment, false, softwareUnderTest);
               runner.TestCompleted += runner_TestCompleted;
               if (!runner.Run())
               {

                  throw new Exception("Unable to run test.");
               }
            }

             });

             System.Console.WriteLine("All tests completed");

             return 0;
        }
Exemplo n.º 3
0
        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;
        }