public static string SaveCurrentRecordingDataAsProjectAsset() { if (RecordedPlaybackPersistentData.GetRecordingMode() != RecordingMode.Record && ReportingManager.IsCrawler) { return(string.Empty); } // TODO use project setting to determine output path string recordingIdentifier = DateTime.Now.ToString("yyyy-MM-dd-THH-mm-ss"); string recordingName = Path.Combine($"recording-{recordingIdentifier}.json"); var outputPath = Path.Combine(AutomatedQARuntimeSettings.RecordingDataPath, recordingName); var mainFile = RecordedPlaybackPersistentData.GetRecordingDataFilePath(); if (!File.Exists(mainFile)) { return(string.Empty); } Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); File.Copy(mainFile, outputPath, false); var recordingFiles = RecordedPlaybackPersistentData.GetSegmentFiles(mainFile); foreach (var recordingFile in recordingFiles) { var segmentPath = Path.Combine(Path.GetDirectoryName(mainFile), recordingFile); var destPath = Path.Combine(AutomatedQARuntimeSettings.RecordingDataPath, recordingFile); Directory.CreateDirectory(Path.GetDirectoryName(destPath)); File.Copy(segmentPath, destPath, true); } AssetDatabase.Refresh(); RecordedPlaybackPersistentData.CleanRecordingData(); RecordedPlaybackAnalytics.SendRecordingCreation(outputPath, new System.IO.FileInfo(outputPath).Length, -1); return(recordingName); }
/// <summary> /// Current recording or Unity test is complete. Finalize data in preperation for next test or end of run. /// </summary> private static void FinalizeTestData() { if (ReportData == null || !ReportData.Tests.Any()) { return; } TestData currentRecording = ReportData.Tests.Last(); if (currentRecording.Status == TestStatus.NotRun.ToString()) { currentRecording.Status = TestStatus.Pass.ToString(); // A pass is determined by whether an exception prevented completion of a step. } if (currentRecording.Steps.Any() && currentRecording.Steps.Last().Status == TestStatus.NotRun.ToString()) { currentRecording.Steps.Last().Status = TestStatus.Pass.ToString(); } if (!currentRecording.InProgress) { return; } currentRecording.EndTime = Time.time; currentRecording.InProgress = false; List <StepData> stepsToUpdate = currentRecording.Steps.FindAll(x => x.Scene.ToLower().Contains("emptyscene")); foreach (StepData step in stepsToUpdate) { step.Scene = SceneManager.GetActiveScene().name; } RecordedPlaybackAnalytics.SendRecordingExecution( RecordedPlaybackPersistentData.kRecordedPlaybackFilename, EntryScene, currentRecording.Status == TestStatus.Pass.ToString(), (int)(currentRecording.EndTime - currentRecording.StartTime) ); IsAutomatorTest = false; }