void Start()
        {
            logger = new AQALogger();
            if (AutomatedQARuntimeSettings.hostPlatform == HostPlatform.Cloud &&
                AutomatedQARuntimeSettings.buildType == BuildType.FullBuild)
            {
                DontDestroyOnLoad(this.gameObject);
                RecordedPlaybackPersistentData.SetRecordingMode(RecordingMode.Playback);
                DeviceFarmConfig dfConf = CloudTestManager.Instance.GetDeviceFarmConfig();
                Application.quitting += () =>
                {
# if UNITY_EDITOR
                    logger.Log($"Counters generated - {CloudTestManager.Instance.GetTestResults().ToString()}");
#else
                    CloudTestManager.UploadCounters();
#endif
                    RuntimeClient.LogTestCompletion(dfConf.testName);
                };

                // Optionally us a settings json file other than the default.
                TextAsset settings = Resources.Load <TextAsset>(Path.GetFileNameWithoutExtension(dfConf.settingsFileToLoad));
                if (!string.IsNullOrEmpty(dfConf.settingsFileToLoad) && settings != null && !string.IsNullOrEmpty(settings.text))
                {
                    logger.Log($"Updating default Automated QA settings file to {dfConf.settingsFileToLoad}");
                    AutomatedQARuntimeSettings.AutomatedQaSettingsFileName = dfConf.settingsFileToLoad;
                    AutomatedQARuntimeSettings.RefreshConfig();
                }
                RunTest(dfConf.testName);
            }
Example #2
0
        public string GetTestResults(DeviceFarmOverrides dfConfOverrides = null)
        {
            DeviceFarmConfig dfConf    = GetDeviceFarmConfig(dfConfOverrides);
            string           dfConfStr = JsonUtility.ToJson(dfConf);
            Metadata         metadata  = new Metadata(dfConf.awsDeviceUDID, attemptId: "", dfConfStr);

            lock (_mutex)
            {
                var countersData = new CountersData(_testResults, metadata);
                return(JsonUtility.ToJson(countersData));
            }
        }
Example #3
0
        public DeviceFarmConfig GetDeviceFarmConfig(DeviceFarmOverrides dfOverrides = null)
        {
            string configPath = Path.Combine(Application.persistentDataPath, deviceFarmConfigFile);

            DeviceFarmConfig dfConf;

            if (File.Exists(configPath))
            {
                // Read env and testName
                string configStr = File.ReadAllText(configPath);
                dfConf = JsonUtility.FromJson <DeviceFarmConfig>(configStr.ToString());
            }
            else
            {
                //TODO: Graceful shutdown with logs.
                logger.Log("config.json not found");
                dfConf             = new DeviceFarmConfig();
                dfConf.testName    = "DummyTest";
                dfConf.packageName = Application.identifier;
            }

            if (dfOverrides != null)
            {
                dfConf.testName      = dfOverrides.testName;
                dfConf.awsDeviceUDID = dfOverrides.awsDeviceUDID;
#if UNITY_IOS
                dfConf.awsDeviceModel = dfOverrides.awsDeviceModel;
                dfConf.awsDeviceName  = GetAppleDevice(dfOverrides.awsDeviceModel);
#else
                dfConf.awsDeviceModel = dfOverrides.awsDeviceModel;
#endif
            }

            logger.Log($"Test name - {dfConf.testName}, Config - {dfConf.ToString()}," +
                       $"Device Model - {dfConf.awsDeviceModel}, Device Name - {dfConf.awsDeviceName}");
            return(dfConf);
        }
 public void RunStarted(ITest testsToRun)
 {
     _dfConf = CloudTestManager.Instance.GetDeviceFarmConfig();
 }