Exemplo n.º 1
0
        private static string GetEvidenceStoreMetadata(IExecutionContext executionContext, TestRunSummary testRunSummary, string testRunner, string name, string description)
        {
            string evidenceStoreMetadataString = string.Empty;

            try
            {
                TestAttestation testAttestation = new TestAttestation(name, testRunner, testRunSummary);
                TestMetadata    testMetadata    = new TestMetadata()
                {
                    Description       = description,
                    HumanReadableName = "Test Results from Publish Test Results utility"
                };

                string pipelinesUrl = GetPipelinesUrl(executionContext);
                if (!string.IsNullOrEmpty(pipelinesUrl))
                {
                    var relatedUrls = new[] { new RelatedUrl()
                                              {
                                                  Label = "pipeline-url", Url = pipelinesUrl
                                              } };
                    testMetadata.RelatedUrls    = relatedUrls;
                    testAttestation.RelatedUrls = relatedUrls;
                }

                testMetadata.SerializedPayload = JsonConvert.SerializeObject(testAttestation);

                EvidenceStoreMetadata evidenceStoreMetadata = new EvidenceStoreMetadata()
                {
                    Name         = Guid.NewGuid().ToString(),
                    ResourceUris = GetResourceUris(executionContext),
                    Metadata     = testMetadata
                };

                evidenceStoreMetadataString = JsonConvert.SerializeObject(evidenceStoreMetadata);
            }
            catch (Exception ex)
            {
                executionContext.Debug($"Unable to construct evidence store metadata, error details: {ex}");
            }

            return(evidenceStoreMetadataString);
        }
Exemplo n.º 2
0
 public static void StoreTestRunSummaryInEnvVar(IExecutionContext executionContext, TestRunSummary testRunSummary, string testRunner, string name, string description = "")
 {
     try
     {
         String evidenceStoreMetadata = JsonConvert.SerializeObject(GetEvidenceStoreMetadata(executionContext, testRunSummary, testRunner, name, description));
         // This Environment variable will be read by the PublishPipelineMetadatTask and publish to Evidence store.
         String envVariableName = "METADATA_" + Guid.NewGuid().ToString();
         Environment.SetEnvironmentVariable("METADATA_" + Guid.NewGuid().ToString(), evidenceStoreMetadata);
         executionContext.Debug($"Setting env variable {envVariableName}: {evidenceStoreMetadata} ");
     }
     catch (Exception ex)
     {
         executionContext.Debug($"Unable to set the METADATA_* env variable, error details: {ex}");
     }
 }