.netreportingspecflowreportportal

Possibility to send reports to one launch in ReportPortal for .net (Specflow)


I have the need to send reports from different OS and test runs to the same launch in the report portal. How this can be done?


Solution

  • Here is how it's accomplished on my project:

    1. CI server creates an RP launch and saves the launch id to app.config of the test binaries.
    2. The test binaries are copied to VMs and run there.
    3. When the tests start, they see that there is launch id in app.config and don't create a new launch - they re-use the existing one. Also they don't close the launch once they are done.

      [BeforeTestRun(Order = -30000)]
      public static void BeforeTestRunPart()
      {
          ReportPortalAddin.BeforeRunStarted += ReportPortalAddin_BeforeRunStarted;
          ReportPortalAddin.BeforeRunFinished += ReportPortalAddin_BeforeRunFinished;
      }
      
      public static void ReportPortalAddin_BeforeRunStarted(object sender, RunStartedEventArgs e)
      {
          var launchId = SettingsManager.CommonSettings.ReportPortalLaunchId;
          if (launchId.IsNullOrEmpty() == false)
          {
              e.Canceled = true;
              Bridge.Context.LaunchId = launchId;
          }
      }
      
      public static void ReportPortalAddin_BeforeRunFinished(object sender, RunFinishedEventArgs e)
      {
          var launchId = SettingsManager.CommonSettings.ReportPortalLaunchId;
          if (launchId.IsNullOrEmpty() == false)
          {
              e.Canceled = true;
          }
      }
      
    4. When all tests are run, CI server closes the RP launch.