コード例 #1
0
        /// <summary>
        /// Execute the current test
        /// </summary>
        /// <returns>Test-Result instance containing all result information</returns>
        public virtual TestResult Execute()
        {
            TestResult testResult = null;

            try
            {
                // Prepare all indicators
                foreach (var indicator in indicators)
                {
                    indicator.Prepare();
                }

                // Before test starts
                foreach (var indicator in indicators)
                {
                    indicator.Start();
                }

                // Execute test
                testResult = Process();

                // Test finished, stop indicator
                foreach (var indicator in indicators)
                {
                    indicator.Stop();
                }

                // free indicator resources
                foreach (var indicator in indicators)
                {
                    indicator.Free();
                }
            }
            catch(Exception ex)
            {
                // Create TestResult and add exception information
                testResult = new TestResult(this);
                testResult.ExitCode = TestCaseExitCode.Error;
                testResult.Message = ex.ToString() + (ex.InnerException == null ? "" : "\r\n" + ex.InnerException.ToString());
            }

            return testResult;
        }
コード例 #2
0
        /// <summary>
        /// Process/execute the test
        /// </summary>
        /// <returns>Result with test results</returns>
        protected override TestResult Process()
        {
            TestResult result = new TestResult(this);
            
            Process process = new Process();

            process.StartInfo.FileName = executable;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;

            if (!string.IsNullOrWhiteSpace(arguments))
            {
                process.StartInfo.Arguments = arguments;
            }

            if (!string.IsNullOrWhiteSpace(workingDirectory))
            {
                process.StartInfo.WorkingDirectory = workingDirectory;
            }

            process.Start();
            process.WaitForExit();

            // set result
            if (process.ExitCode == 0)
            {
                result.ExitCode = TestCaseExitCode.Success;
            }
            else
            {
                result.ExitCode = TestCaseExitCode.Warning;
            }

            result.Message = process.StandardOutput.ReadToEnd();

            return result;
        }
コード例 #3
0
 /// <summary>
 /// Create a new TestCaseReport for reporting the complete result of a testcase
 /// </summary>
 /// <param name="result">Instance of a result class</param>
 /// <param name="indicatorResults">List of indicator results</param>
 public TestCaseReport(TestResult result, IList<IIndicatorResult> indicatorResults)
 {
     this.indicatorResults = indicatorResults;
     this.result = result;
 }