Beispiel #1
0
        /// <summary>
        /// runs a separate ctest call for every testcase
        ///
        /// @maybe use -I to run all test cases
        /// @todo add more metadata to tests!
        /// </summary>
        /// <param name="tests"></param>
        /// <param name="runContext"></param>
        /// <param name="frameworkHandle"></param>
        public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            foreach (var test in tests)
            {
                if (cancelled)
                {
                    break;
                }

                CTestCase ctest   = test;
                var       process = new Process();
                process.StartInfo = new ProcessStartInfo()
                {
                    Arguments              = "-I \"" + ctest.Number + "," + ctest.Number + ",," + ctest.Number + "\"",
                    FileName               = "ctest",
                    WorkingDirectory       = ctest.CMakeBinaryDir,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                    WindowStyle            = ProcessWindowStyle.Hidden
                };

                process.Start();
                var output = process.StandardOutput.ReadToEnd();

                var exitCode = process.ExitCode;

                var testResult = new TestResult(test);
                testResult.Outcome = exitCode == 0 ? TestOutcome.Passed : TestOutcome.Failed;
                frameworkHandle.RecordResult(testResult);
            }
        }
Beispiel #2
0
        /// <summary>
        /// delegates to other RunTests signature
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="runContext"></param>
        /// <param name="frameworkHandle"></param>
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            var tcs = sources.Select(src => (TestCase)CTestCase.Parse(src))
                      .Where(it => it != null)
                      .ToList();

            RunTests(tcs, runContext, frameworkHandle);
        }
 /// <summary>
 /// @todo add more metadata to test cases (however ctest alone does not provide everything needed)
 /// </summary>
 /// <param name="sources"></param>
 /// <param name="discoveryContext"></param>
 /// <param name="logger"></param>
 /// <param name="discoverySink"></param>
 public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
 {
     foreach (var source in sources)
     {
         var testcase = CTestCase.Parse(source);
         if (testcase == null)
         {
             continue;
         }
         discoverySink.SendTestCase(testcase);
     }
 }