diff --git a/src/Microsoft.PowerApps.TestEngine.Tests/ConsoleOutputTests.cs b/src/Microsoft.PowerApps.TestEngine.Tests/ConsoleOutputTests.cs index 3cc233880..4a1493259 100644 --- a/src/Microsoft.PowerApps.TestEngine.Tests/ConsoleOutputTests.cs +++ b/src/Microsoft.PowerApps.TestEngine.Tests/ConsoleOutputTests.cs @@ -204,6 +204,7 @@ class UserInputExceptionDataGenerator : TheoryData public UserInputExceptionDataGenerator() { Add(nameof(UserInputException.ErrorMapping.UserInputExceptionInvalidTestSettings), TestEngineEventHandler.UserInputExceptionInvalidTestSettingsMessage); + Add(nameof(UserInputException.ErrorMapping.UserInputExceptionInvalidOutputPath), TestEngineEventHandler.UserInputExceptionInvalidOutputPathMessage); Add(nameof(UserInputException.ErrorMapping.UserInputExceptionInvalidFilePath), TestEngineEventHandler.UserInputExceptionInvalidFilePathMessage); Add(nameof(UserInputException.ErrorMapping.UserInputExceptionLoginCredential), TestEngineEventHandler.UserInputExceptionLoginCredentialMessage); Add(nameof(UserInputException.ErrorMapping.UserInputExceptionTestConfig), TestEngineEventHandler.UserInputExceptionTestConfigMessage); diff --git a/src/Microsoft.PowerApps.TestEngine/System/UserInputException.cs b/src/Microsoft.PowerApps.TestEngine/System/UserInputException.cs index 535a8f845..690a5d412 100644 --- a/src/Microsoft.PowerApps.TestEngine/System/UserInputException.cs +++ b/src/Microsoft.PowerApps.TestEngine/System/UserInputException.cs @@ -10,6 +10,7 @@ public class UserInputException : Exception public enum ErrorMapping { UserInputExceptionInvalidFilePath, + UserInputExceptionInvalidOutputPath, UserInputExceptionInvalidTestSettings, UserInputExceptionLoginCredential, UserInputExceptionTestConfig, diff --git a/src/Microsoft.PowerApps.TestEngine/TestEngine.cs b/src/Microsoft.PowerApps.TestEngine/TestEngine.cs index 387372db6..32949a811 100644 --- a/src/Microsoft.PowerApps.TestEngine/TestEngine.cs +++ b/src/Microsoft.PowerApps.TestEngine/TestEngine.cs @@ -125,6 +125,11 @@ public async Task RunTestAsync(FileInfo testConfigFile, string environme _eventHandler.EncounteredException(e); return testRunDirectory; } + catch (DirectoryNotFoundException) + { + _eventHandler.EncounteredException(new UserInputException(UserInputException.ErrorMapping.UserInputExceptionInvalidOutputPath.ToString())); + return "InvalidOutputDirectory"; + } catch (Exception e) { Logger.LogError(e.Message); diff --git a/src/Microsoft.PowerApps.TestEngine/TestEngineEventHandler.cs b/src/Microsoft.PowerApps.TestEngine/TestEngineEventHandler.cs index be7c979fd..94800b20d 100644 --- a/src/Microsoft.PowerApps.TestEngine/TestEngineEventHandler.cs +++ b/src/Microsoft.PowerApps.TestEngine/TestEngineEventHandler.cs @@ -17,14 +17,14 @@ public class TestEngineEventHandler : ITestEngineEvents // NOTE: Any changes to these messages need to be handled in the consuming tool's console event handler, like in pac cli tool. // These console messages need to be considered for localization. - public static string UserInputExceptionInvalidTestSettingsMessage = " Invalid test settings specified in testconfig. For more details, check the logs."; + public static string UserAppExceptionMessage = " [Critical Error] Could not access PowerApps. For more details, check the logs."; public static string UserInputExceptionInvalidFilePathMessage = " Invalid file path. For more details, check the logs."; + public static string UserInputExceptionInvalidOutputPathMessage = " [Critical Error]: The output directory provided is invalid."; + public static string UserInputExceptionInvalidTestSettingsMessage = " Invalid test settings specified in testconfig. For more details, check the logs."; public static string UserInputExceptionLoginCredentialMessage = " Invalid login credential(s). For more details, check the logs."; public static string UserInputExceptionTestConfigMessage = " Invalid test config. For more details, check the logs."; public static string UserInputExceptionYAMLFormatMessage = " Invalid YAML format. For more details, check the logs."; - public static string UserAppExceptionMessage = " [Critical Error] Could not access PowerApps. For more details, check the logs."; - public int CasesPassed { get => _casesPassed; set => _casesPassed = value; } public int CasesTotal { get => _casesTotal; set => _casesTotal = value; } @@ -64,6 +64,9 @@ public void EncounteredException(Exception ex) case nameof(UserInputException.ErrorMapping.UserInputExceptionYAMLFormat): Console.WriteLine(UserInputExceptionYAMLFormatMessage); break; + case nameof(UserInputException.ErrorMapping.UserInputExceptionInvalidOutputPath): + Console.WriteLine(UserInputExceptionInvalidOutputPathMessage); + break; default: Console.WriteLine($" {ex.Message}"); break; diff --git a/src/PowerAppsTestEngine/Program.cs b/src/PowerAppsTestEngine/Program.cs index acb81a1f2..a01b00444 100644 --- a/src/PowerAppsTestEngine/Program.cs +++ b/src/PowerAppsTestEngine/Program.cs @@ -178,7 +178,11 @@ //setting defaults for optional parameters outside RunTestAsync var testResult = await testEngine.RunTestAsync(testPlanFile, environmentId, tenantId, outputDirectory, domain, queryParams); - Console.WriteLine($"Test results can be found here: {testResult}"); + if (testResult != "InvalidOutputDirectory") + { + Console.WriteLine($"Test results can be found here: {testResult}"); + } + } catch (Exception ex) {