public InputOptions Parse(string[] args) { _commandLineAccess.WriteToConsole(_messages.Stages.Argument.Status, _messages.Types.Stage); var _inputOptions = new InputOptions(); using (var parser = new Parser(config => config.HelpWriter = null)) { parser.ParseArguments <Options>(args) .WithParsed(o => { _inputOptions.TestType = o.TestType; _inputOptions.DebugMode = o.DebugMode; _inputOptions.Directory = o.Directory; _inputOptions.ProjectName = o.ProjectName; _inputOptions.TestPlanId = int.Parse(o.TestPlanId); _inputOptions.TestSuiteId = int.Parse(o.TestSuiteId); _inputOptions.CollectionUri = o.CollectionUri; _inputOptions.ValidationOnly = o.ValidationOnly; _inputOptions.VerboseLogging = o.VerboseLogging; _inputOptions.PersonalAccessToken = o.PersonalAccessToken; _inputOptions.MinimatchPatterns = o.MinimatchPatterns.Split(';').Select(s => s.ToLowerInvariant()).ToArray(); _inputOptions.TestFrameworkType = o.TestFrameworkType; }); } ValidateInputOptions(_inputOptions); _commandLineAccess.WriteToConsole(_messages.Stages.Argument.Success, _messages.Types.Success); return(_inputOptions); }
public int Associate(TestMethod[] testMethods, Dictionary <string, TestCase> testCases) { foreach (var testMethod in testMethods) { var testCase = GetTestCase(testCases, testMethod); var testCaseNotFound = testCase == null; if (testCaseNotFound) { _outputAccess.WriteToConsole(string.Format(_messages.Associations.TestMethodInfo, testMethod.Name, $"{testMethod.FullClassName}.{testMethod.Name}"), _messages.Types.Error, _messages.Reasons.MissingTestCase); _counter.Error.TestCaseNotFound++; continue; } bool?testCaseHasIncorrectAssociation = null; var testCaseHasAutomatedStatus = testCase.AutomationStatus.Equals(AutomatedName); if (testCaseHasAutomatedStatus) { var testCaseIsAlreadyAutomated = testCase.AutomatedTestName.Equals($"{testMethod.FullClassName}.{testMethod.Name}"); if (testCaseIsAlreadyAutomated) { _counter.Unaffected.AlreadyAutomated++; continue; } testCaseHasIncorrectAssociation = !testCaseIsAlreadyAutomated; if (testCaseHasIncorrectAssociation.Value && _inputOptions.VerboseLogging) { _outputAccess.WriteToConsole(string.Format(_messages.Associations.TestCaseInfo, testCase.Title, testCase.Id), _messages.Types.Info, _messages.Reasons.FixedAssociationTestCase); } } var operationSuccess = AssociateTestCaseWithTestMethod(testCase.Id, $"{testMethod.FullClassName}.{testMethod.Name}", testMethod.AssemblyName, testMethod.TempId.ToString(), _inputOptions.TestType); if (!operationSuccess) { _outputAccess.WriteToConsole(string.Format(_messages.Associations.TestCaseInfo, testCase.Title, testCase.Id), _messages.Types.Failure, _messages.Reasons.Association); _counter.Error.OperationFailed++; continue; } if (_inputOptions.VerboseLogging) { _outputAccess.WriteToConsole(string.Format(_messages.Associations.TestMethodMapped, testMethod.Name, testCase.Id), _messages.Types.Success, _messages.Reasons.Association); } if (testCaseHasIncorrectAssociation.HasValue && testCaseHasIncorrectAssociation.Value) { _counter.Success.FixedReference++; } _counter.Success.Total++; } return(_counter.Error.Total); }
private static AzureDevOpsHttpClients RetrieveHttpClients(VssConnection connection) { _commandLineAccess.WriteToConsole(_messages.Stages.HttpClient.Status, _messages.Types.Stage); var httpClients = new AzureDevOpsHttpClients(); try { httpClients.TestManagementHttpClient = connection.GetClient <TestManagementHttpClient>(); httpClients.WorkItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>(); } catch (Exception e) { var innerException = e.InnerException ?? e; var innerExceptionType = innerException.GetType(); var message = innerException.Message; if (innerExceptionType == typeof(VssServiceResponseException)) { message = string.Format(_messages.Stages.HttpClient.FailureResourceNotFound, _inputOptions.CollectionUri); } else if (innerExceptionType == typeof(VssServiceException)) { message = string.Format(_messages.Stages.HttpClient.FailureUserNotAuthorized, _inputOptions.CollectionUri); } _commandLineAccess.WriteToConsole(message, _messages.Types.Error); throw innerException; } _commandLineAccess.WriteToConsole(_messages.Stages.HttpClient.Success, _messages.Types.Success); return(httpClients); }
public TestMethod[] GetTestMethods(string[] testAssemblyPaths) { _outputAccess.WriteToConsole(_messages.Stages.TestMethod.Status, _messages.Types.Stage); var rawTestMethods = _fileAccess.ListTestMethods(testAssemblyPaths); ValidateTestMethodsIsNullOrEmpty(rawTestMethods); var duplicateTestMethods = _fileAccess.ListDuplicateTestMethods(rawTestMethods); ValidateTestMethodsHasDuplicates(duplicateTestMethods); _outputAccess.WriteToConsole(string.Format(_messages.Stages.TestMethod.Success, rawTestMethods.Length), _messages.Types.Success); return(rawTestMethods.ToTestMethodArray()); }
public void WriteToConsole(string message, string messageType = "", string reason = "") { _outputAccess.WriteToConsole(message, messageType, reason); }