private void StartStep(StepInstance stepInstance) { var stepResult = new StepResult { name = $"{stepInstance.Keyword} {stepInstance.Text}" }; // parse MultilineTextArgument if (stepInstance.MultilineTextArgument != null) { AllureLifecycle.Instance.AddAttachment( "multiline argument", "text/plain", Encoding.UTF8.GetBytes(stepInstance.MultilineTextArgument), ".txt"); } var table = stepInstance.TableArgument; var isTableProcessed = table == null; // parse table as step params if (table != null) { var header = table.Header.ToArray(); if (PluginHelper.SpecFlowCfg.stepArguments.convertToParameters) { var parameters = new List <Parameter>(); // convert 2 column table into param-value if (table.Header.Count == 2) { var paramNameMatch = Regex.IsMatch(header[0], PluginHelper.SpecFlowCfg.stepArguments.paramNameRegex); var paramValueMatch = Regex.IsMatch(header[1], PluginHelper.SpecFlowCfg.stepArguments.paramValueRegex); if (paramNameMatch && paramValueMatch) { for (var i = 0; i < table.RowCount; i++) { parameters.Add(new Parameter { name = table.Rows[i][0], value = table.Rows[i][1] }); } isTableProcessed = true; } } // add step params for 1 row table else if (table.RowCount == 1) { for (var i = 0; i < table.Header.Count; i++) { parameters.Add(new Parameter { name = header[i], value = table.Rows[0][i] }); } isTableProcessed = true; } stepResult.parameters = parameters; } } AllureLifecycle.Instance.StartStep(PluginHelper.NewId(), stepResult); // add csv table for multi-row table if was not processed as params already if (!isTableProcessed) { using (var sw = new StringWriter()) using (var csv = new CsvWriter(sw)) { foreach (var item in table.Header) { csv.WriteField(item); } csv.NextRecord(); foreach (var row in table.Rows) { foreach (var item in row.Values) { csv.WriteField(item); } csv.NextRecord(); } AllureLifecycle.Instance.AddAttachment("table", "text/csv", Encoding.UTF8.GetBytes(sw.ToString()), ".csv"); } } }
public void FirstBeforeScenario() { PluginHelper.StartTestContainer(_featureContext, _scenarioContext); //AllureHelper.StartTestCase(scenarioContainer.uuid, featureContext, scenarioContext); }