Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed encoding of csv attachements to UTF8 #327

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Allure.SpecFlowPlugin/AllureTestTracerWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ private void StartStep(StepInstance stepInstance)

// add csv table for multi-row table if was not processed as params already
if (isTableProcessed) return;
using var sw = new StringWriter();
using var ms = new MemoryStream();
using var sw = new StreamWriter(ms, System.Text.Encoding.UTF8);
using var csv = new CsvWriter(sw, CultureInfo.InvariantCulture);
foreach (var item in table.Header) csv.WriteField(item);
csv.NextRecord();
Expand All @@ -137,8 +138,8 @@ private void StartStep(StepInstance stepInstance)
csv.NextRecord();
}

allure.AddAttachment("table", "text/csv",
Encoding.ASCII.GetBytes(sw.ToString()), ".csv");
sw.Flush();
allure.AddAttachment("table", "text/csv", ms.ToArray(), ".csv");
}

private static void FailScenario(Exception ex)
Expand All @@ -151,4 +152,4 @@ private static void FailScenario(Exception ex)
});
}
}
}
}