Exemplo n.º 1
0
 public A01Run(A01Runs a01Runs, NpgsqlDataReader dataReader)
 {
     this.A01Runs           = a01Runs;
     this.RunId             = dataReader.GetInt64(0);
     this.CreationTimeInUtc = dataReader.GetTimeStamp(1)
                              .ToDateTime()
                              .ToUniversalTime()
                              .ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                throw new ArgumentException("Usage: JUnit_Creatator <start_datetime> <end_datetime>"); // JUnit_Creatator 2018-07-14T00:00:00Z 2018-11-11T00:00:00Z
            }
            DateTime startTime = DateTime.Parse(args[0]);
            DateTime endTime   = DateTime.Parse(args[1]);

            if (startTime > endTime)
            {
                throw new ArgumentException("start_datetime must be before end_datetime");
            }
            //
            Config  config  = Config.Create();
            A01Runs a01Runs = new A01Runs(config.DB);
            //
            IEnumerable <A01Run> a01completedRuns = a01Runs.RetrieveCompletedRuns(utcStartTime: startTime, utcEndTime: endTime);

            foreach (A01Run a01completedRun in a01completedRuns)
            {
                string dirPath = $@"{config.Github.RepoLocalPath}\{Canonalize(a01completedRun.CreationTimeInUtc)}";
                System.IO.Directory.CreateDirectory(dirPath);
                //
                IEnumerable <A01RunTask> failedTasks = a01completedRun.RetrieveFailedTasks();
                foreach (A01RunTask failedTask in failedTasks)
                {
                    string fileName = $@"{dirPath}\{failedTask.TestClassName}_{failedTask.TestName}.xml";
                    //
                    // Tuple<errorType, errorDescription>
                    Tuple <string, string> failure = failedTask.Log.DownloadAndExtractFailure();
                    //
                    XmlDocument junitDocument = JUnitXmlDocument.CreateJUnitDocumentForFailure(testSuiteName: failedTask.TestClassName,
                                                                                               testName: failedTask.TestName,
                                                                                               testDuration: failedTask.TestDurationInSec,
                                                                                               creationTimeInUtc: a01completedRun.CreationTimeInUtc,
                                                                                               failure: failure);
                    SerializeToFile(junitDocument, fileName);
                }
                //
                IEnumerable <A01RunTask> succeededTasks = a01completedRun.RetrieveSucceededTasks();
                foreach (A01RunTask succeededTask in succeededTasks)
                {
                    string fileName = $@"{dirPath}\{succeededTask.TestClassName}_{succeededTask.TestName}.xml";
                    //
                    XmlDocument junitDocument = JUnitXmlDocument.CreateJUnitDocumentForSuccess(testSuiteName: succeededTask.TestClassName,
                                                                                               testName: succeededTask.TestName,
                                                                                               testDuration: succeededTask.TestDurationInSec,
                                                                                               creationTimeInUtc: a01completedRun.CreationTimeInUtc);
                    SerializeToFile(junitDocument, fileName);
                }
            }
            Console.ReadKey();
        }