private void Init(AbstractBuild hudsonBuild, TestResult testResult) { if (testResult != null) { this.TestsFailed = testResult.FailCount; this.TestsPassed = testResult.PassCount; int skipped = testResult.SkipCount; this.TestsTotal = skipped + this.TestsFailed + this.TestsPassed; } this.BuildFinished = !hudsonBuild.Building; var timeStampInMilliseconds = hudsonBuild.Timestamp.ToString().Substring(0, 10); this.StartTime = Epoch.AddSeconds(long.Parse(timeStampInMilliseconds, CultureInfo.InvariantCulture)); this.FinishTime = this.StartTime.Value.AddMilliseconds(hudsonBuild.Duration); this.Status = this.BuildFinished ? GetBuildStatusFromResult(hudsonBuild.Result) : BuildStatus.InProgress; if (hudsonBuild.Culprit == null || hudsonBuild.Culprit.Length == 0) { this.RequestedFor = "anonymous"; } else { this.RequestedFor = hudsonBuild.Culprit[0].FullName; } }
public static TestResult Get(string hudsonUri, string name, int number) { var client = new WebClient(); string testResultString; try { testResultString = client.DownloadString( hudsonUri + "job/" + Uri.EscapeUriString(name) + "/" + number + "/testReport/api/xml"); } catch (WebException) { return null; } TestResult testResult = null; var reader = new StringReader(testResultString); if (testResultString.StartsWith("<testResult>")) { testResult = new TestResult(); var serializer = new XmlSerializer(testResult.GetType()); testResult = (TestResult)serializer.Deserialize(reader); } else if (testResultString.StartsWith("<matrixTestResult>")) { testResult = new MatrixTestResult(); var serializer = new XmlSerializer(testResult.GetType()); testResult = (MatrixTestResult)serializer.Deserialize(reader); } else { var testResultType = testResultString.Substring(1, testResultString.IndexOf('>') - 1); throw new NotSupportedException(string.Format("Unrecognised test result type '{0}'", testResultType)); } return testResult; }
public HudsonBuildInfo(AbstractBuild hudsonBuild, TestResult testResult) { this.Init(hudsonBuild, testResult); }