public StepsBase(FeatureContext featureContext) { app = featureContext.Get <IApp>("App"); shoppingListScreen = featureContext.Get <IShoppingListScreen>(ScreenNames.ShoppingList); shoppingItemScreen = featureContext.Get <IShoppingItemScreen>(ScreenNames.ShoppingItem); }
public static async Task SetupCosmosDbDatabaseForFeature(FeatureContext featureContext) { CosmosDbSettings settings = featureContext.Get <CosmosDbSettings>(); if (settings.CosmosDbAccountUri == null) { throw new NullReferenceException("CosmosDbAccountUri must be set in config."); } ICosmosClientBuilderFactory clientBuilderFactory = ContainerBindings.GetServiceProvider(featureContext).GetRequiredService <ICosmosClientBuilderFactory>(); string accountKey = featureContext.Get <string>(CosmosDbContextKeys.AccountKey); CosmosClientBuilder builder; if (clientBuilderFactory is null) { builder = new CosmosClientBuilder(settings.CosmosDbAccountUri, accountKey); } else { builder = clientBuilderFactory.CreateCosmosClientBuilder(settings.CosmosDbAccountUri, accountKey); } builder = builder .WithConnectionModeDirect(); CosmosClient client = builder.Build(); Database database = await client.CreateDatabaseIfNotExistsAsync(settings.CosmosDbDatabaseName, settings.CosmosDbDefaultOfferThroughput).ConfigureAwait(false); featureContext.Set(client, CosmosDbContextKeys.CosmosDbClient); featureContext.Set(database, CosmosDbContextKeys.CosmosDbDatabase); }
public static void ReportFeatureDuration(FeatureContext context) { var startTime = context.Get <DateTime>("feature_start_time"); var numberOfScenariosInFeature = context.Get <int>("number_of_scenarios_in_feature"); var duration = DateTime.Now - startTime; var telemetry = context.Get <ILifetimeScope>("container_scope") .Resolve <ITelemetry>(); telemetry.TrackEvent($"Finished Feature: {context.FeatureInfo.Title}", new Dictionary <string, string> { { "Type", "Feature" }, { "Feature", context.FeatureInfo.Title }, { "StartTime", startTime.ToString("O") }, { "TestRunId", TestRunId } }, new Dictionary <string, double> { { TelemetryKeys.Duration, duration.TotalMilliseconds }, { "NumberOfScenarios", numberOfScenariosInFeature } } ); lock (LockObject) { numberOfFeatures++; numberOfScenarios += numberOfScenariosInFeature; } }
public WorkflowExecutionLoggingSteps(ScenarioContext scenarioContext, FeatureContext featureContext) { _scenarioContext = scenarioContext ?? throw new ArgumentNullException(nameof(scenarioContext)); _environmentModel = featureContext.Get <IServer>("environmentModel") ?? throw new ArgumentNullException(nameof(featureContext)); _performanceCounterLocater = featureContext.Get <WarewolfPerformanceCounterManager>("performanceCounterLocater"); _principal = featureContext.Get <IPrincipal>("principal"); _environment = BuildExecutionEnvironmet(); }
public void SetupForRedisSource() { _scenarioContext.Add(Utils.ViewNameKey, _featureContext.Get <RedisSourceControl>(Utils.ViewNameKey)); _scenarioContext.Add("updateManager", _featureContext.Get <Mock <IRedisSourceModel> >("updateManager")); _scenarioContext.Add("requestServiceNameViewModel", _featureContext.Get <Mock <IRequestServiceNameViewModel> >("requestServiceNameViewModel")); _scenarioContext.Add("externalProcessExecutor", _featureContext.Get <Mock <IExternalProcessExecutor> >("externalProcessExecutor")); _scenarioContext.Add(Utils.ViewModelNameKey, _featureContext.Get <RedisSourceViewModel>(Utils.ViewModelNameKey)); }
public void GivenIOpenTheAirEmissionsPage() { var moduleName = _featureContext.Get <string>("moduleName"); var pageName = _featureContext.Get <string>("pageName").Replace(" ", ""); var airEmissionsPageUrl = $"{AppSettings.Url}/{moduleName}/{pageName}/Page/1"; _webDriver.Navigate().GoToUrl(airEmissionsPageUrl); }
public static async Task SetupCosmosDbContainerForFeature(FeatureContext featureContext) { string partitionKeyPath = featureContext.Get <string>(CosmosDbContextKeys.PartitionKeyPath); Database database = featureContext.Get <Database>(CosmosDbContextKeys.CosmosDbDatabase); Container container = await database.CreateContainerIfNotExistsAsync("client-" + Guid.NewGuid(), partitionKeyPath).ConfigureAwait(false); featureContext.Set(container, CosmosDbContextKeys.CosmosDbContainer); AddFeatureLevelCosmosDbContainerForCleanup(featureContext, container); }
public void ThenTheQueriesGeneratedShouldAllMatchPreviouslyApprovedValues() { _scenarioContext.TryGetValue(ScenarioContextKeys.RequestCorrelationId, out string correlationId); // These ApprovalTests based on the MemoryAppender seem to be unstable when run in batches // They are restricted to DEBUG only builds for development-level testing when changes are made. var appender = _featureContext.Get <MemoryAppender>(); List <string> queries; if (string.IsNullOrEmpty(correlationId)) { queries = appender.GetEvents() .Where(evt => evt.RenderedMessage.StartsWith("HQL:")) .Select(evt => evt.RenderedMessage) .ToList(); appender.Clear(); } else { queries = appender.GetEvents() .Where(evt => evt.RenderedMessage.StartsWith(string.Format("HQL[{0}]:", correlationId))) // Normalize the output, removing the correlation Id .Select(evt => Regex.Replace(evt.RenderedMessage, @"HQL\[[0-9a-f]{32}\]:", "HQL:")) .ToList(); } Approvals.Verify(string.Join($"{Environment.NewLine}", queries)); }
protected static void DisposeDriver(FeatureContext featureContext) { var driver = featureContext.Get <IWebDriver>(); if (driver == null) { return; } driver.Quit(); driver.Dispose(); if (!System.Diagnostics.Debugger.IsAttached) { return; } if (driver.GetType().Name != "ChromeDriver") { return; } try { ProcessService.KillProcessAndChildren("chromedriver.exe"); } catch { // ignored } }
public static void BeforeFeature2( TestThreadContext testThreadContext, FeatureContext featureContext) { featureContext.Set(new Stopwatch(), nameof(FeatureStopwatch)); featureContext.Get <Stopwatch>(nameof(FeatureStopwatch)).Start(); }
internal static TestResult StartTestCase(string containerId, FeatureContext featureContext, ScenarioContext scenarioContext) { var featureInfo = featureContext?.FeatureInfo ?? emptyFeatureInfo; var scenarioInfo = scenarioContext?.ScenarioInfo ?? emptyScenarioInfo; var testResult = new TestResult() { uuid = NewId(), historyId = scenarioInfo.Title, name = scenarioInfo.Title, fullName = scenarioInfo.Title, labels = new List <Label>() { Label.Thread(), Label.Host(), Label.Suite(featureInfo.Title), } .Union(GetTags(featureInfo, scenarioInfo)).ToList() }; AllureLifecycle.Instance.StartTestCase(containerId, testResult); scenarioContext?.Set(testResult); featureContext.Get <HashSet <TestResult> >().Add(testResult); return(testResult); }
internal static TestResult StartTestCase(string containerId, FeatureContext featureContext, ScenarioContext scenarioContext) { var featureInfo = featureContext?.FeatureInfo ?? emptyFeatureInfo; var scenarioInfo = scenarioContext?.ScenarioInfo ?? emptyScenarioInfo; var tags = GetTags(featureInfo, scenarioInfo); var parameters = GetParameters(scenarioInfo); var title = scenarioInfo.Title; var testResult = new TestResult { uuid = NewId(), historyId = title + parameters.hash, name = title, fullName = title, labels = new List <Label> { Label.Thread(), string.IsNullOrWhiteSpace(AllureLifecycle.Instance.AllureConfiguration.Title) ? Label.Host() : Label.Host(AllureLifecycle.Instance.AllureConfiguration.Title), Label.Feature(featureInfo.Title) } .Union(tags.Item1).ToList(), links = tags.Item2, parameters = parameters.parameters }; AllureLifecycle.Instance.StartTestCase(containerId, testResult); scenarioContext?.Set(testResult); featureContext?.Get <HashSet <TestResult> >().Add(testResult); return(testResult); }
internal static TestResult StartTestCase(string containerId, FeatureContext featureContext, ScenarioContext scenarioContext) { var featureInfo = featureContext?.FeatureInfo ?? EmptyFeatureInfo; var scenarioInfo = scenarioContext?.ScenarioInfo ?? EmptyScenarioInfo; var tags = GetTags(featureInfo, scenarioInfo); var currentTest = TestExecutionContext.CurrentContext.CurrentTest; var fullNameForLog = ReportHelper.GenerateFullNameWithParameters(currentTest, currentTest.FullName); var testResult = new TestResult { uuid = NewId(), historyId = fullNameForLog, name = scenarioInfo.Title, fullName = fullNameForLog, labels = new List <Label> { Label.Thread(), string.IsNullOrWhiteSpace(AllureLifecycle.Instance.Config.Allure.Title) ? Label.Host() : Label.Host(AllureLifecycle.Instance.Config.Allure.Title), Label.Feature(featureInfo.Title) } .Union(tags.Item1).ToList(), links = tags.Item2 }; AllureLifecycle.Instance.StartTestCase(containerId, testResult); scenarioContext?.Set(testResult); featureContext?.Get <HashSet <TestResult> >().Add(testResult); ReportHelper.AddToTestCaseParametersInfo(currentTest, testResult.uuid, new[] { -1 }, new[] { -1 }); return(testResult); }
public static void WriteOutput(FeatureContext featureContext) { ILogger logger = featureContext.Get <ILogger>(); FunctionsController functionsController = FunctionsBindings.GetFunctionsController(featureContext); logger.LogAllAndClear(functionsController.GetFunctionsOutput()); }
public void AddBookingIsCalled(HeaderParameter headers) { var environmentSettings = _gContext.EnvironmentContext; var requestBody = _context.Get <AddRequestModel>(StepKey.BookingDetails); var requestParameter = new RequestParameter(environmentSettings.BaseAddress, environmentSettings.Path, headers, HttpMethod.Post, requestBody); var response = _apiController.Execute(requestParameter); _context.Set(StepKey.AddBookingResponseMessage, response); if (response.IsSuccessStatusCode) { var resultAsString = _apiController.ReadContentAsString(response); var result = JsonConvert.DeserializeObject <AddResponseModel>(resultAsString); _context.Set(StepKey.AddBookingSuccess, result); } }
private static List <DateTime> GetRegistrationAttempts(this FeatureContext featureContext) { if (!featureContext.TryGetValue(RegistrationAttempts, out List <DateTime> _)) { SetRegistrationAttempts(featureContext, new List <DateTime>()); } return(featureContext.Get <List <DateTime> >(RegistrationAttempts)); }
public OgrenciYonetimModuluOgrenciListeleme(FeatureContext featureContext) { FeatureContext = featureContext; factory = featureContext.Get <SmsWebApplicationFactory <Startup> >("SmsWebApplicationcontext"); httpClient = factory.CreateClient(); optionManager = factory.OptionManager; }
public static T EntityId <T>(this FeatureContext context) { if (!context.Keys.Contains(nameof(EntityId))) { return(default(T)); } return(context.Get <T>(nameof(EntityId))); }
public OgrenciYonetimModuluOgrenciEkleme(ScenarioContext scenarioContext, FeatureContext featureContext) { scenarioContext = scenarioContext; FeatureContext = featureContext; factory = featureContext.Get <SmsWebApplicationFactory <Startup> >("SmsWebApplicationcontext"); httpClient = factory.CreateClient(); optionManager = factory.OptionManager; }
public void AfterScenario(FeatureContext featureContext, ScenarioContext scenarioContext) { Console.WriteLine($"Completed scenario: {scenarioContext.ScenarioInfo.Title}"); var driver = featureContext.Get <Navigator>(App).Driver; featureContext.Remove(App); driver.Quit(); }
public static IWebDriver Driver(this FeatureContext scenarioContext) { if (!scenarioContext.ContainsKey(typeof(IWebDriver).FullName)) { scenarioContext.Set((IWebDriver) new FirefoxDriver()); } return(scenarioContext.Get <IWebDriver>()); }
public static void RecordFeatureStartTime(FeatureContext context) { var telemetry = context.Get <ILifetimeScope>("container_scope") .Resolve <ITelemetry>(); telemetry.TrackEvent($"Starting Feature: {context.FeatureInfo.Title}"); context.Set(DateTime.Now, "feature_start_time"); context.Set(0, "number_of_scenarios_in_feature"); }
private static List <DateTime> GetLoginAttempts(this FeatureContext featureContext) { List <DateTime> loginAttempts; if (!featureContext.TryGetValue(LoginAttempts, out loginAttempts)) { SetLoginAttempts(featureContext, new List <DateTime>()); } return(featureContext.Get <List <DateTime> >(LoginAttempts)); }
private static List <DateTime> GetLoginAttempts(this FeatureContext featureContext) { List <DateTime> loginAttempts = null; if (!featureContext.TryGetValue <List <DateTime> >(LOGIN_ATTEMPTS, out loginAttempts)) { SetLoginAttempts(featureContext, new List <DateTime>()); } return(featureContext.Get <List <DateTime> >(LOGIN_ATTEMPTS)); }
public static Task StopContentManagementFunction(FeatureContext context) { return(context.RunAndStoreExceptionsAsync(async() => { await OpenApiWebHostManager.GetInstance(context).StopAllFunctionsAsync().ConfigureAwait(false); HttpClient httpClient = context.Get <HttpClient>(); httpClient.Dispose(); })); }
public static Task TearDownTransientTenant(FeatureContext context) { return(context.RunAndStoreExceptionsAsync(() => { IServiceProvider provider = ContainerBindings.GetServiceProvider(context); ITenantProvider tenantProvider = provider.GetRequiredService <ITenantProvider>(); ITenant tenant = context.Get <ITenant>(); return tenantProvider.DeleteTenantAsync(tenant.Id); })); }
public Steps(FeatureContext featureContext, ScenarioContext scenarioContext) { _featureContext = featureContext; _scenarioContext = scenarioContext; _cancellationToken = new Lazy <CancellationToken>(() => _featureContext.Get <CancellationToken>()); _connectionStringProvider = new Lazy <IOdsDatabaseConnectionStringProvider>( () => { var provider = (IOdsDatabaseConnectionStringProvider)_featureContext.Get <IServiceProvider>() .GetService(typeof(IOdsDatabaseConnectionStringProvider)); provider.ShouldNotBeNull(); return(provider); }); _edFiTestUriHelper = new EdFiTestUriHelper(CompositesTestConstants.BaseUrl); }
public static void BeforeFeature2( TestThreadContext testThreadContext, FeatureContext featureContext) { var testThreadStopWatch = featureContext.Get <Stopwatch>(nameof(TestThreadStopWatch)); testThreadStopWatch.Stop(); testThreadContext.Get <Logger>(nameof(Logger)).Information( $"Elapsed time in the TestThread: {Math.Round(testThreadStopWatch.Elapsed.TotalSeconds, 2)} seconds"); }
public void GivenItHasWith(string groupName, string groupRights) { var groupPermssions = new WindowsGroupPermission { WindowsGroup = groupName, ResourceID = Guid.Empty, IsServer = true }; var permissionsStrings = groupRights.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries); foreach (var permissionsString in permissionsStrings) { if (Enum.TryParse(permissionsString.Replace(" ", ""), true, out SecPermissions permission)) { groupPermssions.Permissions |= permission; } } var settings = new Data.Settings.Settings { Security = new SecuritySettingsTO(new List <WindowsGroupPermission> { groupPermssions }) }; var environmentModel = _featureContext.Get <IServer>("environment"); EnsureEnvironmentConnected(environmentModel); environmentModel.ResourceRepository.WriteSettings(environmentModel, settings); environmentModel.Disconnect(); }
public void AfterStep(FeatureContext feature, ScenarioContext scenario) { var driver = feature.Get <Navigator>(App).Driver; if (scenario.TestError != null) { ScreenshotUtil.TakeScreenshot( driver, feature.FeatureInfo.Title.ToIdentifier(), scenario.ScenarioInfo.Title.ToIdentifier(), $"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()} \n{scenario.ScenarioInfo.Title} \n{scenario.TestError.Message}"); } }