Reputation: 1
Hooks.cs
[BeforeTestRun]
public static void BeforeTestRun()
{
_ = new RpExtension("some feature title");
}
RpExtension.cs
public class RpExtension
{
private string _featureTitle;
public RpExtension(string featureTitle)
{
_featureTitle = featureTitle;
ReportPortalAddin.BeforeRunStarted += ReportPortalAddin_OnBeforeRunStarted;
}
private void ReportPortalAddin_OnBeforeRunStarted(object sender, RunStartedEventArgs e)
{
e.StartLaunchRequest.Description = $"Feature: {_featureTitle}";
}
}
I know that we cant get FeatureContext in BeforeTestRun, but I want to set feature title in launch description.
Upvotes: 0
Views: 108
Reputation: 1
[BeforeTestRun]
public static void BeforeTestRun()
{
ReportPortalAddin.BeforeRunStarted += ReportPortalAddin_OnBeforeRunStarted;
}
private static async void ReportPortalAddin_OnBeforeRunStarted(object sender, RunStartedEventArgs e)
{
await Task.Run(() =>
{
Wait.For(() => FeatureContext.Current != null
&& FeatureContext.Current.FeatureInfo != null
&& !string.IsNullOrEmpty(FeatureContext.Current.FeatureInfo.Title));
e.StartLaunchRequest.Description = FeatureContext.Current.FeatureInfo.Title;
}
}
Upvotes: 0