Example #1
0
        static string BuildExecutionString(DeviceSet.Platform platform, DeviceSet deviceSet, IEnumerable <string> categories,
                                           string series, string account, string user, string outputFile = null, IEnumerable <string> excludeCategories = null)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append(ConsolePath);
            stringBuilder.Append(" submit ");

            switch (platform)
            {
            case DeviceSet.Platform.Android:
                stringBuilder.Append(ApkPath);
                break;

            case DeviceSet.Platform.IOs:
                stringBuilder.Append(IpaPath);
                break;

            case DeviceSet.Platform.IOsClassic:
                stringBuilder.Append(IpaClassicPath);
                break;
            }

            stringBuilder.Append(" ");
            stringBuilder.Append(account);
            stringBuilder.Append(" --user ");
            stringBuilder.Append(user);
            stringBuilder.Append(" --devices ");
            stringBuilder.Append(deviceSet.Id);

            foreach (var category in categories)
            {
                stringBuilder.Append($" --include {category}");
            }

            if (excludeCategories != null)
            {
                foreach (var category in excludeCategories)
                {
                    stringBuilder.Append($" --exclude {category}");
                }
            }

            if (!string.IsNullOrEmpty(series))
            {
                stringBuilder.Append(" --series ");
                stringBuilder.Append(series);
            }

            stringBuilder.Append(" --locale \"en_US\"");

            switch (platform)
            {
            case DeviceSet.Platform.Android:
                stringBuilder.Append(" --app-name \"AndroidControlGallery\"");
                break;

            case DeviceSet.Platform.IOs:
            case DeviceSet.Platform.IOsClassic:
                stringBuilder.Append(" --app-name \"XamControl\"");
                break;
            }

            stringBuilder.Append(" --assembly-dir ");

            if (platform == DeviceSet.Platform.Android)
            {
                stringBuilder.Append(AndroidTestingDirectory);
            }
            else
            {
                stringBuilder.Append(iOSTestingDirectory);
            }

            stringBuilder.Append(" --fixture-chunk");

            if (!string.IsNullOrEmpty(outputFile))
            {
                stringBuilder.Append($" --nunit-xml {outputFile}");
            }

            return(stringBuilder.ToString());
        }
Example #2
0
        static int Main(string[] args)
        {
            loaderActions = new LoaderActions();

            var       categories        = new List <string>();
            var       excludeCategories = new List <string>();
            string    series            = null;
            var       platform          = DeviceSet.Platform.None;
            DeviceSet deviceSet         = null;
            var       validate          = false;
            string    outputFile        = null;
            var       account           = "";
            var       user = "";

            OptionSet optionSet = null;

            optionSet = new OptionSet
            {
                {
                    "p|platform=", "specify the test platform, iOS or Android",
                    s => platform = (DeviceSet.Platform)Enum.Parse(typeof(DeviceSet.Platform), s)
                },
                { "d|deviceset=", "the device set to use for the test run", s => deviceSet = StringToDeviceSet(s) },
                { "c|category=", "add a category to the test run [deprecated, use include]", str => categories.Add(str) },
                { "s|series=", "specify the series when uploaded to Test Cloud", s => series = s },
                { "l|list", "list categories available in test suite", ListCategories },
                { "sets", "list available device sets", ListDeviceSets },
                { "i|interactive", "start uploader in interactive mode", InteractiveMode },
                { "h|help", "show this message and exit", s => ShowHelp(optionSet) },
                { "v|validate", "validate all tests or a specified category", s => validate = true },
                { "o|output=", "output destination for NUnit XML", s => outputFile = s },
                { "a|account=", "Test Cloud key", s => account = s },
                { "u|user="******"Test Cloud user", s => user = s },
                { "n|include=", "add a category to the test run", str => categories.Add(str) },
                { "e|exclude=", "exclude a category from the test run", str => excludeCategories.Add(str) }
            };

            List <string> extra;

            try
            {
                extra = optionSet.Parse(args);
            }
            catch (OptionException ex)
            {
                Console.Write("Uploader:");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try --help for more informaiton");
            }

            if (args.Length == 0)
            {
                ShowHelp(optionSet);
            }

            if (validate)
            {
                var category = categories.FirstOrDefault();
                return(loaderActions.ValidateCategory(category) ? 0 : 1);
            }

            if (platform == DeviceSet.Platform.None)
            {
                Console.WriteLine("Platform must be specified");
                return(1);
            }

            if (deviceSet != null && !deviceSet.DeviceSetPlatform.Contains(platform))
            {
                Console.WriteLine("DeviceSet platform does not match specified platform");
                return(1);
            }

            if (deviceSet == null)
            {
                if (platform == DeviceSet.Platform.Android)
                {
                    deviceSet = DeviceSets.AndroidFastParallel;
                }
                else
                {
                    deviceSet = DeviceSets.IOsFastParallel;
                }
            }

            var execString = BuildExecutionString(platform, deviceSet, categories, series, account, user, outputFile, excludeCategories);

            Console.WriteLine(execString);

            var processStatus = TestCloudUtils.UploadApp(execString);

            Console.WriteLine("test-cloud.exe status: " + processStatus);
            return(processStatus);
        }
Example #3
0
		static string BuildExecutionString(DeviceSet.Platform platform, DeviceSet deviceSet, IEnumerable<string> categories,
			string series, string account, string user, string outputFile = null)
		{
			var stringBuilder = new StringBuilder();
			stringBuilder.Append(ConsolePath);
			stringBuilder.Append(" submit ");

			switch (platform)
			{
				case DeviceSet.Platform.Android:
					stringBuilder.Append(ApkPath);
					break;
				case DeviceSet.Platform.IOs:
					stringBuilder.Append(IpaPath);
					break;
				case DeviceSet.Platform.IOsClassic:
					stringBuilder.Append(IpaClassicPath);
					break;
			}

			stringBuilder.Append(" ");
			stringBuilder.Append(account);
			stringBuilder.Append(" --user ");
			stringBuilder.Append(user);
			stringBuilder.Append(" --devices ");
			stringBuilder.Append(deviceSet.Id);

			foreach (var category in categories)
			{
				stringBuilder.Append(" --include ");
				stringBuilder.Append(category);
			}

			if (!string.IsNullOrEmpty(series))
			{
				stringBuilder.Append(" --series ");
				stringBuilder.Append(series);
			}

			stringBuilder.Append(" --locale \"en_US\"");

			switch (platform)
			{
				case DeviceSet.Platform.Android:
					stringBuilder.Append(" --app-name \"AndroidControlGallery\"");
					break;
				case DeviceSet.Platform.IOs:
				case DeviceSet.Platform.IOsClassic:
					stringBuilder.Append(" --app-name \"XamControl\"");
					break;
			}

			stringBuilder.Append(" --assembly-dir ");

			if (platform == DeviceSet.Platform.Android)
				stringBuilder.Append(AndroidTestingDirectory);
			else
				stringBuilder.Append(iOSTestingDirectory);

			stringBuilder.Append(" --fixture-chunk");

			if (!string.IsNullOrEmpty(outputFile))
				stringBuilder.Append($" --nunit-xml {outputFile}");

			return stringBuilder.ToString();
		}