Beispiel #1
0
        static string GetConsoleRunnerArguments(TestRunParameters parms)
        {
            string where = string.Empty;
            if (!string.IsNullOrWhiteSpace(parms.NUnitWhere))
            {
                where = $"--where \"{parms.NUnitWhere}\" ";
            }

            string nUnitArgs = $"";

#if DEBUG || OSX
            //TODO: if we make the process include the nunit executable, this is not needed
            nUnitArgs = $"{_nunit3Path} ";
#endif

            nUnitArgs += $"--work {parms.TestResultDirectory} " + where +
                         AddTestParamIfValueIsAvailable("deviceId", parms.DeviceId) +
                         AddTestParamIfValueIsAvailable("deviceName", parms.DeviceName) +
                         AddTestParamIfValueIsAvailable("deviceIp", parms.DeviceIPAddress) +
                         $"--testparam deviceIndex={parms.DeviceIndex} " +
                         $"--testparam appFilePath={Path.Combine(parms.DropDirectory, parms.AppPackageName)} " +
                         $"--testparam dropDir={parms.DropDirectory} " +
                         $"--testparam testResultDirectory={parms.TestResultDirectory} " +
                         $"{Path.Combine(parms.DropDirectory, parms.UITestDllName)} ";

            return(nUnitArgs);
        }
        private void Button_Confirm_Click(object sender, RoutedEventArgs e)
        {
            string origianlName = this.testProject.Name;

            this.testProject.Name              = this.TextBoxTestProjectName.Text;
            this.testProject.TestTarget        = this.TextBoxTestTargetName.Text;
            this.testProject.TestTargetVersion = this.TextBoxTestTargetVersion.Text;

            Dictionary <string, object> dict = new Dictionary <string, object>();

            foreach (TestRunParameter pair in this.listBoxKeyValuePair.Items)
            {
                dict.Add(pair.Name, pair.Value);
            }

            TestRunParameters.SaveTestRunParameters(dict, this.runsettingsFile);

            if (origianlName != this.testProject.Name)
            {
                IConfigurationManager configuration = (App.Current as App).Container.GetService <IConfigurationManager>();
                this.testProject.Rename(origianlName, configuration.GetConfigValue(Constants.DefaultRunsettingsFile), configuration.GetEncoding());
            }

            this.DialogResult = true;

            this.Close();
        }
        private static void SetDevModeDefaultParams()
        {
            TestRunParameters.isDevelopmentMode = true;
            TestRunParameters.Set(nameof(Constants.RS_LocalExecutionAsService), "false");
            TestRunParameters.Set(nameof(Constants.RS_LocalExecution), "true");
            TestRunParameters.Set(nameof(Constants.RS_AppType), ApplicationType.WEB.ToString());
            TestRunParameters.Set(nameof(Constants.RS_ServerHost), Constants.RS_ServerHost);
            TestRunParameters.Set(nameof(Constants.RS_ServerPort), Constants.RS_ServerPort);
            TestRunParameters.Set(nameof(Constants.RS_ServerResource), Constants.RS_ServerResource);
            TestRunParameters.Set(nameof(Constants.RS_AppiumJSPath), Constants.RS_AppiumJSPath);
            TestRunParameters.Set(nameof(Constants.RS_NodeExePath), Constants.RS_NodeExePath);
            TestRunParameters.Set(nameof(Constants.RS_PlatformName), Constants.RS_PlatformName);
            TestRunParameters.Set(nameof(Constants.RS_NewCommandTimeout), Constants.RS_NewCommandTimeout);
            TestRunParameters.Set(nameof(Constants.RS_ImplicitWaitTime), Constants.RS_ImplicitWaitTime);
            TestRunParameters.Set(nameof(Constants.RS_DeviceReadyTimeout), Constants.RS_DeviceReadyTimeout);
            TestRunParameters.Set(nameof(Constants.RS_AppActivity), Constants.RS_AppActivity);
            TestRunParameters.Set(nameof(Constants.RS_AppPackage), Constants.RS_AppPackage);
            TestRunParameters.Set(nameof(Constants.RS_AppPackagePath), Constants.RS_AppPackagePath);
            TestRunParameters.Set(nameof(Constants.RS_AppPassword), Constants.RS_AppPassword);
            TestRunParameters.Set(nameof(Constants.RS_BrowserName), Constants.RS_BrowserName);
            TestRunParameters.Set(nameof(Constants.RS_DeviceName), Constants.RS_DeviceName);
            TestRunParameters.Set(nameof(Constants.RS_PlatformVersion), Constants.RS_PlatformVersion);
            TestRunParameters.Set(nameof(Constants.RS_AutoDownloadChromeDriver), Constants.RS_AutoDownloadChromeDriver);

            TestRunParameters.Set(nameof(Constants.RS_DeviceGroup), Constants.RS_DeviceGroup);
            //TestRunParameters.Set(nameof(Constants.RS_XcodeSigninId), Constants.RS_XcodeSigninId);
        }
Beispiel #4
0
        public EnvironmentConfiguration()
        {
            this.RS_BrowserName        = TestRunParameters.Get(nameof(Constants.RS_BrowserName)) ?? Constants.RS_BrowserName;
            this.RS_AppType            = TestRunParameters.Get(nameof(Constants.RS_AppType)) ?? Constants.RS_AppType;
            this.ImplicitWaitTime      = TestRunParameters.Get(nameof(Constants.RS_ImplicitWaitTime)) ?? Constants.RS_ImplicitWaitTime;
            this.RS_DeviceName         = TestRunParameters.Get(nameof(Constants.RS_DeviceName)) ?? Constants.RS_DeviceName;
            this.RS_AppActivity        = TestRunParameters.Get(nameof(Constants.RS_AppActivity)) ?? Constants.RS_AppActivity;
            this.RS_AppPackagePath     = TestRunParameters.Get(nameof(Constants.RS_AppPackagePath)) ?? Constants.RS_AppPackagePath;
            this.RS_AppPackage         = TestRunParameters.Get(nameof(Constants.RS_AppPackage)) ?? Constants.RS_AppPackage;
            this.RS_AppPassword        = TestRunParameters.Get(nameof(Constants.RS_AppPassword)) ?? Constants.RS_AppPassword;
            this.RS_ServerPort         = TestRunParameters.Get(nameof(Constants.RS_ServerPort)) ?? Constants.RS_ServerPort;
            this.RS_PlatformName       = TestRunParameters.Get(nameof(Constants.RS_PlatformName)) ?? Constants.RS_PlatformName;
            this.RS_NewCommandTimeout  = TestRunParameters.Get(nameof(Constants.RS_NewCommandTimeout)) ?? Constants.RS_NewCommandTimeout;
            this.RS_DeviceReadyTimeout = TestRunParameters.Get(nameof(Constants.RS_DeviceReadyTimeout)) ?? Constants.RS_DeviceReadyTimeout;
            this.RS_PlatformVersion    = TestRunParameters.Get(nameof(Constants.RS_PlatformVersion)) ?? Constants.RS_PlatformVersion;
            this.RS_ServerHost         = TestRunParameters.Get(nameof(Constants.RS_ServerHost)) ?? Constants.RS_ServerHost;
            this.RS_ServerResource     = TestRunParameters.Get(nameof(Constants.RS_ServerResource)) ?? Constants.RS_ServerResource;
            this.RS_DeviceGroup        = TestRunParameters.Get(nameof(Constants.RS_DeviceGroup)) ?? Constants.RS_DeviceGroup;

            this.RS_NodeExePath              = TestRunParameters.Get(nameof(Constants.RS_NodeExePath)) ?? Constants.RS_NodeExePath;
            this.RS_AppiumJSPath             = TestRunParameters.Get(nameof(Constants.RS_AppiumJSPath)) ?? Constants.RS_AppiumJSPath;
            this.RS_AutoDownloadChromeDriver = TestRunParameters.Get(nameof(Constants.RS_AutoDownloadChromeDriver)) ?? Constants.RS_AutoDownloadChromeDriver;
            this.RS_LocalExecutionAsService  = TestRunParameters.Get(nameof(Constants.RS_LocalExecutionAsService)) ?? Constants.RS_LocalExecutionAsService;
            this.RS_LocalExecution           = TestRunParameters.Get(nameof(Constants.RS_LocalExecution)) ?? Constants.RS_LocalExecution;
        }
Beispiel #5
0
        private async Task <TestRunParameters> GetTestRunParametersAsync(string resultsDirectory)
        {
            TestRunParameters testRunParameters = new TestRunParameters
            {
                DeviceName          = DeviceName ?? string.Empty,
                DeviceIndex         = DeviceIndex,
                DropDirectory       = LocalPath,
                TestResultDirectory = resultsDirectory,
                UITestDllName       = UITestDllName,
                AppPackageName      = AppPackageName,
                NUnitWhere          = NUnitWhere
            };

            if (DevicePlatform == Platform.Android)
            {
                //For Android, we just take a DeviceID (we don't need to specify and IP Address
                testRunParameters.DeviceId = DeviceId;
            }
            else if (DevicePlatform == Platform.iOS)
            {
                //For IPhone we take a device name and resolve the ID and IP Address
                testRunParameters.DeviceId        = iOSDeviceUtility.GetIPhoneIdByName(DeviceName);
                testRunParameters.DeviceIPAddress = await GetDeviceIPAddress(DeviceIpAddress, DeviceName);
            }

            return(testRunParameters);
        }
Beispiel #6
0
 public TestEventsContext(
     EventsContextOptions options,
     IRootAppServiceProvider rootAppServiceProvider,
     TestRunParameters parameters
     )
     : base(options, rootAppServiceProvider)
 {
     _parameters = parameters;
 }
 /// <summary>
 /// Set/override default test run parameters.
 /// </summary>
 /// <param name="key">parameter key</param>
 /// <param name="value">parameter value</param>
 public static void Set(string key, string value)
 {
     if (!TestRunParameters.isDevelopmentMode)
     {
         throw new InvalidOperationException("Cannot update when default values not set. Call Get method first(and only once) before updating default values.");
     }
     if (string.IsNullOrEmpty(key))
     {
         return;
     }
     TestRunParameters.Set(key, value, true);
 }
        public static void SaveToFile(this TestProjectInfo project, string defaultRunsettingsFile, Encoding encoding)
        {
            if (!Directory.Exists(project.Location))
            {
                Directory.CreateDirectory(project.Location);
            }

            string output  = TestProjectInfo.Serialize(project);
            string srcFile = Path.Combine(project.Location, project.Name + Constants.TestProjectFileTypeExtension);

            File.WriteAllText(srcFile, output, encoding);
            string runsettingsFile = Path.Combine(project.Location, project.Name + Constants.TestRunSettingFileTypeExtesion);

            if (!File.Exists(runsettingsFile))
            {
                File.Copy(defaultRunsettingsFile, runsettingsFile, true);
            }

            string xml = File.ReadAllText(runsettingsFile);
            Dictionary <string, object> dict           = VsualStudioTP.XmlRunSettingsUtilities.GetTestRunParameters(xml);
            IEnumerable <string>        testAssemblies = (from r in project.TestMethods select r.Source).Distinct(StringComparer.InvariantCultureIgnoreCase);

            foreach (string assembly in testAssemblies)
            {
                DirectoryInfo root = new DirectoryInfo(Path.GetDirectoryName(assembly));
                if (!root.Exists)
                {
                    continue;
                }
                foreach (FileInfo info in root.GetFiles(Constants.TestRunSettingFileTypePattern))
                {
                    xml = File.ReadAllText(info.FullName);
                    Dictionary <string, object> tmp = VsualStudioTP.XmlRunSettingsUtilities.GetTestRunParameters(xml);
                    foreach (KeyValuePair <string, object> keyValue in tmp)
                    {
                        if (dict.ContainsKey(keyValue.Key))
                        {
                            continue;
                        }

                        dict.Add(keyValue.Key, keyValue.Value);
                    }

                    TestRunParameters.AddLegacyNodes(xml, runsettingsFile);
                }
            }

            TestRunParameters.SaveTestRunParameters(dict, runsettingsFile);
        }
Beispiel #9
0
        public static int RunUITests(TestRunParameters parms)
        {
            Logger.Debug("Starting NUnit process:...");
            string process = _nunit3Path;

#if DEBUG || OSX
            //TODO: should we make the process be mono + nunit executable?
            process = "mono";
#endif

            string args = GetConsoleRunnerArguments(parms);
            Logger.Debug($"{process} {args}");
            var(ExitCode, Output) = ProcessRunner.Run(process, args, (s, e) =>
            {
                Logger.Info(e.Data);
            });

            return(ExitCode);
        }
Beispiel #10
0
        private void SetUpContext(TestRunParameters testRunParameters)
        {
            var services = new ServiceCollection();

            services.AddEventsContext <TestEventsContext>(options => { });

            services.AddSingleton(testRunParameters);

            services.AddScoped <ScopedSubscribingService>();
            services.AddSingleton <SingletonSubscribingService>();
            _serviceProvider = services.BuildServiceProvider();

            _entity = new TestEntity();

            var serviceScope = _serviceProvider.CreateScope();

            _scopedSubscribingService    = serviceScope.ServiceProvider.GetRequiredService <ScopedSubscribingService>();
            _singletonSubscribingService = serviceScope.ServiceProvider.GetRequiredService <SingletonSubscribingService>();
            _context     = serviceScope.ServiceProvider.GetRequiredService <TestEventsContext>();
            _eventsScope = serviceScope.ServiceProvider.GetRequiredService <EventsScope>();

            _context.Attach(_entity, _eventsScope);
        }
Beispiel #11
0
        public async Task CombinePipelineModules(
            [Values] bool isAsync,
            [Values] bool isFiltered,
            [Values] bool isProjected,
            [Values] bool isQueued,
            [Values] PublicationType publicationType
            )
        {
            var testRunParameters = new TestRunParameters
            {
                IsAsync         = isAsync,
                IsFiltered      = isFiltered,
                IsProjected     = isProjected,
                IsQueued        = isQueued,
                PublicationType = publicationType
            };

            SetUpContext(testRunParameters);

            await RaiseEvent(isAsync);

            if (isQueued)
            {
                await _context.ProcessQueuedEventsAsync(_eventsScope);
            }

            var subscribingService = publicationType == PublicationType.ScopedWithServiceHandlerSubscription
                ? _scopedSubscribingService
                : _singletonSubscribingService;

            Assert.That(subscribingService,
                        isProjected
                    ? Has.Property(nameof(SubscribingService.ProjectedTestEvents)).With.One.Items
                    : Has.Property(nameof(SubscribingService.TestEvents)).With.One.Items
                        );
        }
 public void Cleanup()
 {
     TestRunParameters.Dispose();
 }
 public override void FixtureTearDown()
 {
     TestRunParameters.Dispose();
     base.FixtureTearDown();
 }