protected override void HandleNewSpec(BeginNewSpec beginNewSpec) { _teamCityFlowWriter = _teamCityTestSuiteWriter.OpenFlow(); _teamCityTestWriter = _teamCityFlowWriter.OpenTest($"{beginNewSpec.ClassName}.{beginNewSpec.MethodName}"); base.HandleNewSpec(beginNewSpec); }
public void SendAttachmentSet(string testName, AttachmentSet attachmentSet, ITeamCityTestWriter testWriter) { var subfolder = _idGenerator.NewId(); foreach (var attachment in attachmentSet.Attachments) { SendAttachment(testName, attachment, testWriter, subfolder); } }
public void SendAttachment(string testName, UriDataAttachment attachment, ITeamCityTestWriter testWriter) { if (testName == null) { throw new ArgumentNullException(nameof(testName)); } if (attachment == null) { throw new ArgumentNullException(nameof(attachment)); } if (testWriter == null) { throw new ArgumentNullException(nameof(testWriter)); } if (!_options.MetadataEnable || !_options.AllowExperimental || _options.Version.CompareTo(_options.TestMetadataSupportVersion) < 0) { testWriter.WriteStdOutput($"Attachment \"{attachment.Description}\": \"{attachment.Uri}\""); return; } if (!attachment.Uri.IsFile) { return; } var filePath = attachment.Uri.LocalPath; if (string.IsNullOrEmpty(filePath)) { return; } var description = attachment.Description ?? string.Empty; if (description == filePath) { description = string.Empty; } var fileName = Path.GetFileName(filePath); var fileExtension = Path.GetExtension(fileName).ToLowerInvariant(); string artifactDir = null; if (!string.IsNullOrEmpty(description)) { var match = AttachmentDescriptionRegex.Match(description); if (match.Success) { description = match.Groups[1].Value.Trim(); artifactDir = match.Groups[2].Value.Trim(); } } if (artifactDir == null) { var testDirName = new string(NormalizeTestName(testName).ToArray()); artifactDir = ".teamcity/VSTest/" + testDirName + "/" + _idGenerator.NewId(); } _rootWriter.PublishArtifact(filePath + " => " + artifactDir); var artifact = artifactDir + "/" + fileName; switch (fileExtension) { case ".bmp": case ".gif": case ".ico": case ".jng": case ".jpeg": case ".jpg": case ".jfif": case ".jp2": case ".jps": case ".tga": case ".tiff": case ".tif": case ".svg": case ".wmf": case ".emf": case ".png": testWriter.WriteImage(artifact, description); break; default: testWriter.WriteFile(artifact, description); break; } }