Example #1
0
		public PythonTestResult(TestResult testResult)
			: base(testResult.Name)
		{
			ResultType = testResult.ResultType;
			Message = testResult.Message;
			StackTrace = testResult.StackTrace;
		}
Example #2
0
		public static SDTask Create(TestResult result, ITestProject project)
		{
			TaskType taskType = TaskType.Warning;
			FileLineReference lineRef = null;
			string message = String.Empty;
			
			if (result.IsFailure) {
				taskType = TaskType.Error;
				if (!result.StackTraceFilePosition.IsEmpty) {
					lineRef = new FileLineReference(result.StackTraceFilePosition.FileName, result.StackTraceFilePosition.BeginLine - 1, result.StackTraceFilePosition.BeginColumn - 1);
				}
				message = GetTestFailedMessage(result);
			} else if (result.IsIgnored) {
				message = GetTestIgnoredMessage(result);
			}
			if (lineRef == null) {
				lineRef = FindTest(result.Name, project);
			}
			FileName fileName = null;
			if (lineRef != null) {
				fileName = new FileName(Path.GetFullPath(lineRef.FileName));
				int line = lineRef.Line + 1;
				return new SDTask(fileName, message, lineRef.Column, line, taskType);
			}
			return new SDTask(fileName, message, 0, 0, taskType);
		}
        TestResult BuildTestResultFrom(XmlNode node)
        {
            var className = node.SelectSingleNode("../@type-name").InnerText;
            var result = new TestResult(className + "." + node.Attributes["field-name"].InnerText);
            switch (node.Attributes["status"].InnerText)
            {
                case "failed":
                    result.ResultType = TestResultType.Failure;
                    break;
                case "passed":
                    result.ResultType = TestResultType.Success;
                    break;
				case "not-implemented":
				case "ignored":
					result.ResultType = TestResultType.Ignored;
            		break;
            }
            var errorNode = node.SelectSingleNode("error");
            if (errorNode != null)
            {
                var messageNode = errorNode.SelectSingleNode("message");
                result.Message = messageNode.InnerText;

                var stackTraceNode = errorNode.SelectSingleNode("stack-trace");
                result.StackTrace = stackTraceNode.InnerText;
            }
            return result;
        }
Example #4
0
		/// <summary>
		/// Returns the test result message if there is on otherwise
		/// uses the string resource to create a message.
		/// </summary>
		static string GetTestResultMessage(TestResult result, string stringResource)
		{
			if (result.Message.Length > 0) {
				return result.Message;
			}
			return GetTestResultMessageFromResource(result, stringResource);
		}
		public NUnitTestResult(TestResult testResult)
			: base(testResult.Name)
		{
			Message = testResult.Message;
			ResultType = testResult.ResultType;
			StackTrace = testResult.StackTrace;
		}
		public override void UpdateTestResult(TestResult result)
		{
			// Code duplication - taken from NUnitTestProject
			int lastDot = result.Name.LastIndexOf('.');
			if (lastDot < 0)
				return;
			
			string fixtureName = result.Name.Substring(0, lastDot);
			string memberName = result.Name.Substring(lastDot + 1);
			
			var testClass = GetMSpecTestClass(new FullTypeName(fixtureName)) as MSpecTestClass;
			MSpecTestMember test = testClass.FindTestMember(memberName);
			if (test != null)
				test.UpdateTestResult(result);
		}
Example #7
0
		public override void UpdateTestResult(TestResult result)
		{
			int lastDot = result.Name.LastIndexOf('.');
			if (lastDot < 0)
				return;
			string fixtureName = result.Name.Substring(0, lastDot);
			string methodName = result.Name.Substring(lastDot + 1);
			NUnitTestClass testClass = GetTestClass(new FullTypeName(fixtureName));
			if (testClass == null) {
				// maybe it's an inherited test
				int secondToLastDot = result.Name.LastIndexOf('.', lastDot - 1);
				if (secondToLastDot >= 0) {
					string fixtureName2 = result.Name.Substring(0, secondToLastDot);
					methodName = result.Name.Substring(secondToLastDot + 1);
					testClass = GetTestClass(new FullTypeName(fixtureName2));
				}
			}
			if (testClass != null) {
				NUnitTestMethod testMethod = testClass.FindTestMethod(methodName);
				if (testMethod != null) {
					testMethod.UpdateTestResult(result);
				}
			}
		}
		/// <summary>
		/// Creates and updates a TestResult based on the
		/// name-value pair read in,
		/// </summary>
		/// <returns>True if a TestResult is ready to be returned
		/// to the caller.</returns>
		/// <remarks>
		/// The first name-value pair for a test result is the
		/// test name. The last name-value pair is the result of
		/// the test (Success, Failure or Ignored).</remarks>
		bool ReadTestResult()
		{
			string name = nameBuilder.ToString();
			if (name == "Name") {
				result = new TestResult(valueBuilder.ToString());
			} else if (result != null) {
				if (name == "Message") {
					result.Message = valueBuilder.ToString();
				} else if (name == "StackTrace") {
					result.StackTrace = valueBuilder.ToString();
				} else if (name == "Result") {
					UpdateTestSuccess();
					return true;
				}
			}
			return false;
		}
 public abstract void UpdateTestResult(TestResult result);
Example #10
0
		static string GetTestResultMessageFromResource(TestResult result, string stringResource)
		{
			return StringParser.Parse(stringResource, new StringTagPair("TestCase", result.Name));
		}
		public TestFinishedEventArgs(TestResult result)
		{
			this.result = result;
		}
		bool IsTestResultFailureOrIsIgnored(TestResult result)
		{
			return result.IsFailure || result.IsIgnored;
		}
		public abstract void UpdateTestResult(TestResult result);
		void OnTestResultsReceived(TestResult[] results)
		{
			if (results.Length > 0 && TestFinished != null) {
				foreach (TestResult result in results) {
					TestFinished(this, new TestFinishedEventArgs(result));
				}
			}
		}
Example #15
0
		/// <summary>
		/// Updates the test method based on the test result.
		/// </summary>
		public void UpdateTestResult(TestResult testResult)
		{
			TestClasses.UpdateTestResult(testResult);
		}
Example #16
0
		/// <summary>
		/// Updates the test method with the specified test result.
		/// </summary>
		public void UpdateTestResult(TestResult testResult)
		{
			TestMethod method = null;
			string methodName = TestMethod.GetMethodName(testResult.Name);
			if (methodName != null) {
				method = GetTestMethod(methodName);
				if (method == null) {
					method = GetPrefixedTestMethod(testResult.Name);
				}
			}
			if (method != null) {
				method.Result = testResult.ResultType;
			}
		}
		public TestResult CallCreateTestResultForTestFramework(TestResult testResult)
		{
			return base.CreateTestResultForTestFramework(testResult);
		}
Example #18
0
		/// <summary>
		/// Updates the test member with the specified test result.
		/// </summary>
		public void UpdateTestResult(TestResult testResult)
		{
			TestMember member = null;
			string memberName = TestMember.GetMemberName(testResult.Name);
			if (memberName != null) {
				member = GetTestMember(memberName);
				if (member == null) {
					member = GetPrefixedTestMember(testResult.Name);
				}
			}
			if (member != null) {
				member.Result = testResult.ResultType;
			}
		}
		void UpdateProgressMonitorStatus(TestResult result)
		{
			if (testProgressMonitor != null) {
				if (result.IsFailure) {
					testProgressMonitor.Status = OperationStatus.Error;
				} else if (result.IsIgnored && testProgressMonitor.Status == OperationStatus.Normal) {
					testProgressMonitor.Status = OperationStatus.Warning;
				}
			}
		}
		void UpdateTestResult(TestResult result)
		{
			TestProject testProject = GetTestProjectForProject(selectedTests.Project);
			if (testProject != null) {
				testProject.UpdateTestResult(result);
			}
		}
		void AddTaskForTestResult(TestResult testResult)
		{
			TestProject project = GetTestProjectForProject(selectedTests.Project);
			Task task = TestResultTask.Create(testResult, project);
			context.TaskService.Add(task);
		}
		void PublishTestResults(TestResult[] testResults)
		{
			if (TestFinished != null) {
				foreach (TestResult result in testResults) {
					if (!reportedResults.Contains(result.Name)) {
						TestFinished(this, new TestFinishedEventArgs(new NUnitTestResult(result)));
						reportedResults.Add(result.Name);
					}
				}
			}
		}
Example #23
0
 /// <summary>
 /// Updates the test method based on the test result.
 /// </summary>
 public void UpdateTestResult(TestResult testResult)
 {
     TestClasses.UpdateTestResult(testResult);
 }
Example #24
0
		public void FireTestFinishedEvent(TestResult testResult)
		{
			if (TestFinished != null) {
				TestFinished(this, new TestFinishedEventArgs(testResult));
			}
		}
Example #25
0
		static string GetTestResultMessageFromResource(TestResult result, string stringResource)
		{
			string [,] customTags = new string[,] {{"TestCase", result.Name}};
			return StringParser.Parse(stringResource, customTags);
		}
		public void FireTestFinishedEvent(TestResult testResult)
		{
			OnTestFinished(new TestFinishedEventArgs(testResult));
		}
Example #27
0
 public TestFinishedEventArgs(TestResult result)
 {
     this.result = result;
 }
Example #28
0
		protected virtual TestResult CreateTestResultForTestFramework(TestResult testResult)
		{
			return testResult;
		}
Example #29
0
		static string GetTestIgnoredMessage(TestResult result)
		{
			string resource = "${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}";
			return GetTestResultMessage(result, resource);
		}
Example #30
0
		public void UpdateTestResult(TestResult result)
		{
			this.Result = result.ResultType;
		}
		protected void ShowResult(TestResult result)
		{
			if (IsTestResultFailureOrIsIgnored(result)) {
				AddTaskForTestResult(result);
				UpdateProgressMonitorStatus(result);
			}
			UpdateTestResult(result);
		}
Example #32
0
		protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
		{
			return new RubyTestResult(testResult);
		}
Example #33
0
 protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
 {
     return testResult;
 }