public void OnNavigatedTo(NavigationContext context) { try { _archiveType = (ArchiveType)context.Parameters["archiveType"]; _archiveFileName = (string)context.Parameters["archiveFileName"]; _testSession = Directory.Exists(_archiveFileName) ? _arkadeApi.CreateTestSession(ArchiveDirectory.Read(_archiveFileName, _archiveType)) : _arkadeApi.CreateTestSession(ArchiveFile.Read(_archiveFileName, _archiveType)); if (!_testSession.IsTestableArchive()) { _statusEventHandler.RaiseEventOperationMessage( Resources.GUI.TestrunnerArchiveTestability, string.Format(Resources.GUI.TestrunnerArchiveNotTestable, ArkadeProcessingArea.LogsDirectory), OperationMessageStatus.Warning ); } StartTestingCommand.RaiseCanExecuteChanged(); // testSession has been updated, reevaluate command } catch (Exception e) { string message = string.Format(Resources.GUI.ErrorReadingArchive, e.Message); Log.Error(e, message); _statusEventHandler.RaiseEventOperationMessage(null, message, OperationMessageStatus.Error); } }
private static TestSession CreateTestSession(CommandLineOptions options, Core.Arkade arkade, ArchiveType archiveType) { TestSession testSession; if (File.Exists(options.Archive)) { Log.Debug("File exists"); testSession = arkade.RunTests(ArchiveFile.Read(options.Archive, archiveType)); } else if (Directory.Exists(options.Archive)) { Log.Debug("Directory exists"); testSession = arkade.RunTests(ArchiveDirectory.Read(options.Archive, archiveType)); } else { throw new ArgumentException("Invalid archive path: " + options.Archive); } return(testSession); }
private void RunTests() { try { NotifyStartRunningTests(); if (Directory.Exists(_archiveFileName)) { _testSession = _arkadeApi.RunTests(ArchiveDirectory.Read(_archiveFileName, _archiveType)); } else { _testSession = _arkadeApi.RunTests(ArchiveFile.Read(_archiveFileName, _archiveType)); } _testSession.TestSummary = new TestSummary(_numberOfProcessedFiles, _numberOfProcessedRecords, _numberOfTestsFinished); _testSession.AddLogEntry("Test run completed."); SaveHtmlReport(); _testRunCompletedSuccessfully = true; _statusEventHandler.RaiseEventOperationMessage(Resources.UI.TestrunnerFinishedOperationMessage, null, OperationMessageStatus.Ok); NotifyFinishedRunningTests(); } catch (ArkadeException e) { _testSession?.AddLogEntry("Test run failed: " + e.Message); _log.Error(e.Message, e); _statusEventHandler.RaiseEventOperationMessage(Resources.UI.TestrunnerFinishedWithError, e.Message, OperationMessageStatus.Error); NotifyFinishedRunningTests(); } catch (Exception e) { _testSession?.AddLogEntry("Test run failed: " + e.Message); _log.Error(e.Message, e); var operationMessageBuilder = new StringBuilder(); if (e.GetType() == typeof(FileNotFoundException)) { string nameOfMissingFile = new FileInfo(((FileNotFoundException)e).FileName).Name; operationMessageBuilder.Append(string.Format(Resources.UI.FileNotFoundMessage, nameOfMissingFile)); } else { operationMessageBuilder.Append(e.Message); } string fileName = new DetailedExceptionMessage(e).WriteToFile(); if (!string.IsNullOrEmpty(fileName)) { operationMessageBuilder.AppendLine("\n" + string.Format(Resources.UI.DetailedErrorMessageInfo, fileName)); } string operationMessage = operationMessageBuilder.ToString(); _statusEventHandler.RaiseEventOperationMessage( Resources.UI.TestrunnerFinishedWithError, operationMessage, OperationMessageStatus.Error ); NotifyFinishedRunningTests(); } }