Exemplo n.º 1
0
        private void Events_TestRunStart(object sender, TestRunStartEventArgs e)
        {
            var requestNewLaunch = new StartLaunchRequest
            {
                Name        = _config.GetValue(ConfigurationPath.LaunchName, "VsTest Launch"),
                Description = _config.GetValue(ConfigurationPath.LaunchDescription, ""),
                StartTime   = DateTime.UtcNow
            };

            if (_config.GetValue(ConfigurationPath.LaunchDebugMode, false))
            {
                requestNewLaunch.Mode = LaunchMode.Debug;
            }

            requestNewLaunch.Tags = _config.GetValues(ConfigurationPath.LaunchTags, new List <string>()).ToList();

            // see wether we need use external launch
            var launchId = _config.GetValue <string>("Launch:Id", "");

            if (string.IsNullOrEmpty(launchId))
            {
                _launchReporter = new LaunchReporter(Bridge.Service);
            }
            else
            {
                _launchReporter = new LaunchReporter(Bridge.Service, launchId);
            }

            _launchReporter.Start(requestNewLaunch);
        }
Exemplo n.º 2
0
        public static void BeforeTestRun()
        {
            try
            {
                var config = Initialize();

                var request = new StartLaunchRequest
                {
                    Name      = config.GetValue(ConfigurationPath.LaunchName, "SpecFlow Launch"),
                    StartTime = DateTime.UtcNow
                };

                if (config.GetValue(ConfigurationPath.LaunchDebugMode, false))
                {
                    request.Mode = LaunchMode.Debug;
                }

                request.Attributes = config.GetKeyValues("Launch:Attributes", new List <KeyValuePair <string, string> >()).Select(a => new ItemAttribute {
                    Key = a.Key, Value = a.Value
                }).ToList();
                request.Description = config.GetValue(ConfigurationPath.LaunchDescription, string.Empty);

                var eventArg = new RunStartedEventArgs(_service, request);
                ReportPortalAddin.OnBeforeRunStarted(null, eventArg);

                if (eventArg.LaunchReporter != null)
                {
                    _launchReporter = eventArg.LaunchReporter;
                }

                if (!eventArg.Canceled)
                {
                    Shared.Extensibility.Embedded.Analytics.AnalyticsReportEventsObserver.DefineConsumer("agent-dotnet-specflow");

                    _launchReporter = _launchReporter ?? new LaunchReporter(_service, config, null, Shared.Extensibility.ExtensionManager.Instance);

                    _launchReporter.Start(request);

                    ReportPortalAddin.OnAfterRunStarted(null, new RunStartedEventArgs(_service, request, _launchReporter));
                }
            }
            catch (Exception exp)
            {
                _traceLogger.Error(exp.ToString());
            }
        }
Exemplo n.º 3
0
        private void Events_TestRunStart(object sender, TestRunStartEventArgs e)
        {
            var requestNewLaunch = new StartLaunchRequest
            {
                Name        = _config.GetValue(ConfigurationPath.LaunchName, "VsTest Launch"),
                Description = _config.GetValue(ConfigurationPath.LaunchDescription, ""),
                StartTime   = DateTime.UtcNow
            };

            if (_config.GetValue(ConfigurationPath.LaunchDebugMode, false))
            {
                requestNewLaunch.Mode = LaunchMode.Debug;
            }

            requestNewLaunch.Tags = _config.GetValues(ConfigurationPath.LaunchTags, new List <string>()).ToList();

            _launchReporter = new LaunchReporter(Bridge.Service, _config, null);

            _launchReporter.Start(requestNewLaunch);
        }
Exemplo n.º 4
0
        private void Events_TestRunStart(object sender, TestRunStartEventArgs e)
        {
            try
            {
                var apiUri     = _config.GetValue <string>(ConfigurationPath.ServerUrl);
                var apiProject = _config.GetValue <string>(ConfigurationPath.ServerProject);
                var apiToken   = _config.GetValue <string>(ConfigurationPath.ServerAuthenticationUuid);
                var apiService = new Service(new Uri(apiUri), apiProject, apiToken);

                var requestNewLaunch = new StartLaunchRequest
                {
                    Name              = _config.GetValue(ConfigurationPath.LaunchName, "VsTest Launch"),
                    Description       = _config.GetValue(ConfigurationPath.LaunchDescription, ""),
                    StartTime         = DateTime.UtcNow,
                    RerunOfLaunchUuid = Environment.GetEnvironmentVariable("DTA.RerunIterationCount") != null ? this._config.Properties["RerunOfLaunchUuid"].ToString() : null,
                };
                if (_config.GetValue(ConfigurationPath.LaunchDebugMode, false))
                {
                    requestNewLaunch.Mode = LaunchMode.Debug;
                }

                requestNewLaunch.Attributes = _config.GetKeyValues("Launch:Attributes", new List <KeyValuePair <string, string> >()).Select(a => new ItemAttribute {
                    Key = a.Key, Value = a.Value
                }).ToList();

                _launchReporter = new LaunchReporter(apiService, _config, null);

                _launchReporter.Start(requestNewLaunch);
            }
            catch (Exception exp)
            {
                var error = $"Unexpected exception in {nameof(Events_TestRunStart)}: {exp}";
                TraceLogger.Error(error);
                Console.WriteLine(error);
                throw;
            }
        }