Ejemplo n.º 1
0
		public PythonTestResult(TestResult testResult)
			: base(testResult.Name)
		{
			ResultType = testResult.ResultType;
			Message = testResult.Message;
			StackTrace = testResult.StackTrace;
		}
Ejemplo n.º 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);
		}
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 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);
		}
Ejemplo n.º 5
0
		public NUnitTestResult(TestResult testResult)
			: base(testResult.Name)
		{
			Message = testResult.Message;
			ResultType = testResult.ResultType;
			StackTrace = testResult.StackTrace;
		}
Ejemplo n.º 6
0
		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);
		}
Ejemplo n.º 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);
				}
			}
		}
Ejemplo n.º 8
0
		/// <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;
		}
Ejemplo n.º 9
0
 public abstract void UpdateTestResult(TestResult result);
Ejemplo n.º 10
0
		static string GetTestResultMessageFromResource(TestResult result, string stringResource)
		{
			return StringParser.Parse(stringResource, new StringTagPair("TestCase", result.Name));
		}
Ejemplo n.º 11
0
		public TestFinishedEventArgs(TestResult result)
		{
			this.result = result;
		}
Ejemplo n.º 12
0
		bool IsTestResultFailureOrIsIgnored(TestResult result)
		{
			return result.IsFailure || result.IsIgnored;
		}
Ejemplo n.º 13
0
		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));
				}
			}
		}
Ejemplo n.º 15
0
		/// <summary>
		/// Updates the test method based on the test result.
		/// </summary>
		public void UpdateTestResult(TestResult testResult)
		{
			TestClasses.UpdateTestResult(testResult);
		}
Ejemplo n.º 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);
		}
Ejemplo n.º 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;
			}
		}
Ejemplo n.º 19
0
		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;
				}
			}
		}
Ejemplo n.º 20
0
		void UpdateTestResult(TestResult result)
		{
			TestProject testProject = GetTestProjectForProject(selectedTests.Project);
			if (testProject != null) {
				testProject.UpdateTestResult(result);
			}
		}
Ejemplo n.º 21
0
		void AddTaskForTestResult(TestResult testResult)
		{
			TestProject project = GetTestProjectForProject(selectedTests.Project);
			Task task = TestResultTask.Create(testResult, project);
			context.TaskService.Add(task);
		}
Ejemplo n.º 22
0
		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);
					}
				}
			}
		}
Ejemplo n.º 23
0
 /// <summary>
 /// Updates the test method based on the test result.
 /// </summary>
 public void UpdateTestResult(TestResult testResult)
 {
     TestClasses.UpdateTestResult(testResult);
 }
Ejemplo n.º 24
0
		public void FireTestFinishedEvent(TestResult testResult)
		{
			if (TestFinished != null) {
				TestFinished(this, new TestFinishedEventArgs(testResult));
			}
		}
Ejemplo n.º 25
0
		static string GetTestResultMessageFromResource(TestResult result, string stringResource)
		{
			string [,] customTags = new string[,] {{"TestCase", result.Name}};
			return StringParser.Parse(stringResource, customTags);
		}
Ejemplo n.º 26
0
		public void FireTestFinishedEvent(TestResult testResult)
		{
			OnTestFinished(new TestFinishedEventArgs(testResult));
		}
Ejemplo n.º 27
0
 public TestFinishedEventArgs(TestResult result)
 {
     this.result = result;
 }
Ejemplo n.º 28
0
		protected virtual TestResult CreateTestResultForTestFramework(TestResult testResult)
		{
			return testResult;
		}
Ejemplo n.º 29
0
		static string GetTestIgnoredMessage(TestResult result)
		{
			string resource = "${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}";
			return GetTestResultMessage(result, resource);
		}
Ejemplo n.º 30
0
		public void UpdateTestResult(TestResult result)
		{
			this.Result = result.ResultType;
		}
Ejemplo n.º 31
0
		protected void ShowResult(TestResult result)
		{
			if (IsTestResultFailureOrIsIgnored(result)) {
				AddTaskForTestResult(result);
				UpdateProgressMonitorStatus(result);
			}
			UpdateTestResult(result);
		}
Ejemplo n.º 32
0
		protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
		{
			return new RubyTestResult(testResult);
		}
Ejemplo n.º 33
0
 protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
 {
     return testResult;
 }