Exemplo n.º 1
0
 public void DoesNotRunCategoryThatIsExcluded()
 {
     var setupData = new RunnerSetupData
     {
         WorkingDirectory = workingDir,
         DryRun = true,
         Results = Path.GetTempFileName(),
         Continuous = false,
         IsTesting = true,
         ExcludedCategory = "Failure"
     };
     var runner = new TestRunner(setupData);
     runner.SetupTests();
     Assert.AreEqual(runner.GetRunnableTests().Count(), 3);
 }
Exemplo n.º 2
0
        public static IRunnerSetupData ParseCommandLineArguments(IEnumerable<string> args)
        {
            var showHelp = false;

            var setupData = new RunnerSetupData();

            var p = new OptionSet()
            {
                {"dir=","The path to the working directory.", v=> setupData.WorkingDirectory = Path.GetFullPath(v)},
                {"a=|assembly=", "The path to the test assembly.", v => setupData.TestAssembly = Path.GetFullPath(v)},
                {"r=|results=", "The path to the results file.", v=>setupData.Results = Path.GetFullPath(v)},
                {"f:|fixture:", "The full name (with namespace) of the test fixture.", v => setupData.Fixture = v},
                {"t:|testName:", "The name of a test to run", v => setupData.Test = v},
                {"category:", "The name of a test category to run.", v=> setupData.Category = v},
                {"exclude:", "The name of a test category to exclude.", v=> setupData.ExcludedCategory = v},
                {"c|concatenate", "Concatenate results with existing results file.", v=> setupData.Concat = v != null},
                {"revit:", "The path to Revit.", v=> setupData.RevitPath = v},
                {"copyAddins", "Specify whether to copy the addins from the Revit folder to the current working directory",
                    v=> setupData.CopyAddins = v != null},
                {"dry", "Conduct a dry run.", v=> setupData.DryRun = v != null},
                {"x|clean", "Cleanup journal files after test completion", v=> setupData.CleanUp = v != null},
                {"continuous", "Run all selected tests in one Revit session.", v=> setupData.Continuous = v != null},
                {"d|debug", "Run in debug mode.", v=>setupData.IsDebug = v != null},
                {"h|help", "Show this message and exit.", v=> showHelp = v != null}
            };

            var notParsed = new List<string>();

            const string helpMessage = "Try 'DynamoTestFrameworkRunner --help' for more information.";

            try
            {
                notParsed = p.Parse(args);
            }
            catch (OptionException e)
            {
                string message = e.Message + "\n" + helpMessage;
                throw new Exception(message);
            }

            if (notParsed.Count > 0)
            {
                throw new ArgumentException(String.Join(" ", notParsed.ToArray()));
            }

            if (string.IsNullOrEmpty(setupData.WorkingDirectory))
            {
                throw new Exception("You must specify a working directory.");
            }

            if (string.IsNullOrEmpty(setupData.TestAssembly))
            {
                throw new Exception("You must specify a test assembly.");
            }

            if (string.IsNullOrEmpty(setupData.Results))
            {
                throw new Exception("You must specify a results file.");
            }

            if (showHelp)
            {
                ShowHelp(p);
                throw new Exception();
            }

            return setupData;
        }
Exemplo n.º 3
0
 public void CanConstructDefaultRunner()
 {
     var setupData = new RunnerSetupData();
     Assert.DoesNotThrow(()=>new TestRunner(setupData));
 }
Exemplo n.º 4
0
        private IRunnerSetupData TestSetupData()
        {
            var setupData = new RunnerSetupData
            {
                WorkingDirectory = workingDir,
                DryRun = true,
                Results = Path.GetTempFileName(),
                Continuous = false,
                IsTesting = true
            };

            return setupData;
        }
Exemplo n.º 5
0
        public void RunTwoSelectedCategories()
        {
            var setupData = new RunnerSetupData
            {
                WorkingDirectory = workingDir,
                DryRun = true,
                Results = Path.GetTempFileName(),
                Continuous = false,
                IsTesting = true,
            };
            var runner = new TestRunner(setupData);
            var assData = runner.Assemblies.First();
            assData.ShouldRun = false;

            var catData1 = runner.Assemblies.SelectMany(a => a.Categories).First(c => c.Name == "Smoke");
            ((IExcludable)catData1).ShouldRun = true;

            var catData2 = runner.Assemblies.SelectMany(a => a.Categories).First(c => c.Name == "Integration");
            ((IExcludable)catData2).ShouldRun = true;

            runner.SetupTests();
            Assert.AreEqual(runner.GetRunnableTests().Count(), 3);
        }
Exemplo n.º 6
0
 public void RunsTestIfSpecifiedInParameters()
 {
     var setupData = new RunnerSetupData
     {
         WorkingDirectory = workingDir,
         DryRun = true,
         Results = Path.GetTempFileName(),
         Continuous = false,
         IsTesting = true,
         Test = "TestA"
     };
     var runner = new TestRunner(setupData);
     runner.SetupTests();
     Assert.AreEqual(runner.GetRunnableTests().Count(), 1);
 }
        internal RunnerViewModel(IContext context)
        {
            this.context = context;

            var setupData = new RunnerSetupData
            {
                WorkingDirectory = !String.IsNullOrEmpty(Settings.Default.workingDirectory) &&
                                   Directory.Exists(Settings.Default.workingDirectory)
                    ? Settings.Default.workingDirectory
                    : Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                TestAssembly = !String.IsNullOrEmpty(Settings.Default.assemblyPath) &&
                               File.Exists(Settings.Default.assemblyPath)
                    ? Settings.Default.assemblyPath
                    : null,
                Results = !String.IsNullOrEmpty(Settings.Default.resultsPath)
                    ? Settings.Default.resultsPath
                    : null,
                Timeout = Settings.Default.timeout,
                IsDebug = Settings.Default.isDebug,
            };

            runner = new Runner(setupData);

            if (Settings.Default.selectedProduct > runner.Products.Count - 1)
            {
                SelectedProductIndex = -1;
            }
            else
            {
                SelectedProductIndex = Settings.Default.selectedProduct;
            }

            SetAssemblyPathCommand = new DelegateCommand(SetAssemblyPath, CanSetAssemblyPath);
            SetResultsPathCommand = new DelegateCommand(SetResultsPath, CanSetResultsPath);
            SetWorkingPathCommand = new DelegateCommand(SetWorkingPath, CanSetWorkingPath);
            RunCommand = new DelegateCommand<object>(Run, CanRun);
            SaveSettingsCommand = new DelegateCommand(SaveSettings, CanSaveSettings);
            CleanupCommand = new DelegateCommand(runner.Cleanup, CanCleanup);
            CancelCommand = new DelegateCommand(Cancel, CanCancel);
            UpdateSummaryCommand = new DelegateCommand(UpdateSummary, CanUpdateSummary);

            runner.Products.CollectionChanged += Products_CollectionChanged;

            runner.TestComplete += runner_TestComplete;
            runner.TestFailed += runner_TestFailed;
            runner.TestTimedOut += runner_TestTimedOut;

            watcher = new FileSystemWatcher
            {
                Path = Path.GetDirectoryName(AssemblyPath),
                NotifyFilter = NotifyFilters.LastWrite,
                Filter = Path.GetFileName(AssemblyPath)
            };
            watcher.Changed += watcher_Changed;
            watcher.EnableRaisingEvents = true;
        }