public void BeforeScenario() { _settings = new TestRunImportPluginProfile(); ObjectFactory.Configure( x => x.For <TransportMock>().Use(TransportMock.CreateWithoutStructureMapClear(typeof(TestRunImportPluginProfile).Assembly))); ObjectFactory.Configure(x => x.AddRegistry <TestRunImportEnvironmentRegistry>()); }
protected override void OnBeforeProfileMigrate(TestRunImportPluginProfile profile) { base.OnBeforeProfileMigrate(profile); if (string.IsNullOrEmpty(profile.ResultsFilePath)) { profile.PostResultsToRemoteUrl = true; } }
private TestRunImportPluginProfile Parse(XmlNode document) { var result = new TestRunImportPluginProfile { FrameworkType = FrameworkType }; var root = document.SelectSingleNode(string.Format("./{0}", SettingsXmlNode)); result.ResultsFilePath = GetValueByName(root, "TestResultFilePathForXMLSerializer"); var syncIntervalValue = GetValueByName(root, "IntegrationInterval"); if (!string.IsNullOrEmpty(syncIntervalValue)) { var syncInterval = Int32.Parse(syncIntervalValue); if (syncInterval > 0) { result.SynchronizationInterval = syncInterval * 60; } } var passiveModeValue = GetValueByName(root, "PassiveMode"); if (!string.IsNullOrEmpty(passiveModeValue)) { result.PassiveMode = bool.Parse(passiveModeValue); } var testPlanIdValue = GetValueByName(root, "TestPlanID"); if (!string.IsNullOrEmpty(testPlanIdValue)) { var testPlanId = Int32.Parse(testPlanIdValue); var testPlan = _context.TestPlans.FirstOrDefault(x => x.TestPlanID == testPlanId); if (testPlan != null) { result.Project = testPlan.ProjectID.GetValueOrDefault(); result.TestPlan = testPlan.TestPlanID; } } var regexpValue = GetValueByName(root, "Regexp"); if (!string.IsNullOrEmpty(regexpValue)) { result.RegExp = regexpValue; } var testResultFileLastModifyTimeUtcValue = GetValueByName(root, "TestResultFileLastModifyTimeUtc"); if (!string.IsNullOrEmpty(testResultFileLastModifyTimeUtcValue)) { TestResultFileLastModifyTimeUtc = DateTime.Parse(testResultFileLastModifyTimeUtcValue).ToUniversalTime(); } return(result); }
private static CheckMappingResult CheckMapping(TestRunImportPluginProfile settings, IEnumerable<TestCaseLightDto> testCases) { var testCaseTestPlanDtos = testCases.Select( testCaseLightDto => new TestCaseTestPlanDTO {TestCaseID = testCaseLightDto.Id, TestCaseName = testCaseLightDto.Name}).ToList(); var errors = new PluginProfileErrorCollection(); settings.ValidateMapperData(errors); return ObjectFactory.GetInstance<IMappingChecker>().CheckMapping(settings, testCaseTestPlanDtos, errors); }
public void BeforeScenario() { ObjectFactory.Configure( x => x.For <TransportMock>().Use(TransportMock.CreateWithoutStructureMapClear(typeof(TestRunImportPluginProfile).Assembly))); ObjectFactory.Configure(x => x.AddRegistry <TestRunImportEnvironmentRegistry>()); Settings = new TestRunImportPluginProfile { FrameworkType = FrameworkType }; _testCaseTestPlanDtos = new List <TestCaseTestPlanDTO>(); }
private static CheckMappingResult CheckMapping(TestRunImportPluginProfile settings, IEnumerable <TestCaseLightDto> testCases) { var testCaseTestPlanDtos = testCases.Select( testCaseLightDto => new TestCaseTestPlanDTO { TestCaseID = testCaseLightDto.Id, TestCaseName = testCaseLightDto.Name }).ToList(); var errors = new PluginProfileErrorCollection(); settings.ValidateMapperData(errors); return(ObjectFactory.GetInstance <IMappingChecker>().CheckMapping(settings, testCaseTestPlanDtos, errors)); }
public void Init() { ObjectFactory.Initialize(x => x.AddRegistry <TestRunImportEnvironmentRegistry>()); ObjectFactory.Configure(x => x.For <TransportMock>().Use(TransportMock.CreateWithoutStructureMapClear(typeof(TestRunImportPluginProfileInitializationSagaData).Assembly))); _profileSettings = new TestRunImportPluginProfile { PassiveMode = false, Project = 1, ResultsFilePath = "C:\\SimpleTestCaseTestResult.xml", TestPlan = 1, FrameworkType = FrameworkTypes.NUnit }; }
public void ValidateProfileForMapping(TestRunImportPluginProfile settings, PluginProfileErrorCollection errors) { settings.ValidateMapperData(errors); }
public CheckMappingResult CheckMapping(TestRunImportPluginProfile settings, IEnumerable <TestCaseTestPlanDTO> testCaseTestPlans, PluginProfileErrorCollection errors) { try { var uri = settings.FrameworkType == FrameworkTypes.FrameworkTypes.JenkinsHudson ? new Uri(string.Format("{0}/lastCompletedBuild/testReport/api/xml", settings.ResultsFilePath.TrimEnd(new[] { '/', '\\' }))) : new Uri(settings.ResultsFilePath); var factoryResult = _streamFactory.OpenStream(uri, settings.PassiveMode); if (factoryResult != null) { using (factoryResult.Stream) { using (var reader = new StreamReader(factoryResult.Stream)) { try { var result = _resultsReaderFactory.GetResolver(settings, reader).GetTestRunImportResults(); if (result.Count > 0) { var resolver = _resolverFactory.GetResolver(settings, result, testCaseTestPlans); return(resolver.ResolveTestCaseNames(errors)); } } catch (ApplicationException) { throw; } catch (XmlException ex) { throw new ApplicationException("Error parsing NUnit results XML file", ex); } catch (Exception ex) { throw new ApplicationException("Error importing NUnit results XML file", ex); } } } } } catch (UriFormatException ex) { errors.Add(new PluginProfileError { FieldName = "ResultsFilePath", Message = ex.Message }); } catch (ApplicationException ex) { errors.Add(new PluginProfileError { FieldName = "ResultsFilePath", Message = ex.Message }); } catch (Exception ex) { errors.Add(new PluginProfileError { FieldName = "ResultsFilePath", Message = string.Format("Could not read file \"{0}\": {1}", settings.ResultsFilePath, ex.Message) }); } return(new CheckMappingResult { Errors = errors, NamesMappers = new List <NamesMapper>() }); }
public CheckMappingResult CheckMapping(TestRunImportPluginProfile settings, IEnumerable<TestCaseTestPlanDTO> testCaseTestPlans, PluginProfileErrorCollection errors) { try { var uri = settings.FrameworkType == FrameworkTypes.FrameworkTypes.JenkinsHudson ? new Uri(string.Format("{0}/lastCompletedBuild/testReport/api/xml", settings.ResultsFilePath.TrimEnd(new[] { '/', '\\' }))) : new Uri(settings.ResultsFilePath); var factoryResult = _streamFactory.OpenStream(uri, settings.PassiveMode); if (factoryResult != null) { using (factoryResult.Stream) { using (var reader = new StreamReader(factoryResult.Stream)) { try { var result = _resultsReaderFactory.GetResolver(settings, reader).GetTestRunImportResults(); if (result.Count > 0) { var resolver = _resolverFactory.GetResolver(settings, result, testCaseTestPlans); return resolver.ResolveTestCaseNames(errors); } } catch (ApplicationException) { throw; } catch (XmlException ex) { throw new ApplicationException("Error parsing NUnit results XML file", ex); } catch (Exception ex) { throw new ApplicationException("Error importing NUnit results XML file", ex); } } } } } catch (UriFormatException ex) { errors.Add(new PluginProfileError { FieldName = "ResultsFilePath", Message = ex.Message }); } catch (ApplicationException ex) { errors.Add(new PluginProfileError { FieldName = "ResultsFilePath", Message = ex.Message }); } catch (Exception ex) { errors.Add(new PluginProfileError { FieldName = "ResultsFilePath", Message = string.Format("Could not read file \"{0}\": {1}", settings.ResultsFilePath, ex.Message) }); } return new CheckMappingResult { Errors = errors, NamesMappers = new List<NamesMapper>() }; }
protected virtual void OnBeforeProfileMigrate(TestRunImportPluginProfile profile) { }
public void AddProfile(string profileName, TestRunImportPluginProfile settings) { CurrentProfile = Transport.AddProfile(profileName, settings); }