コード例 #1
0
        public virtual void TestTearDown()
        {
            try {
                if (TestContext.CurrentContext.Result.Outcome != ResultState.Success)
                {
                    Screenshot.Attach();
                }

                TestLogs.AddSection($"Test {TestContext.CurrentContext.Test.Name} Ends");
                TestLogs.Attach();
            } catch (Exception e) {
                throw new Exception($"Teardown failed. Urgent attention required!!! Exception: \n {e}");
            } finally {
                MobileDriver.Dispose();
            }
        }
コード例 #2
0
 public virtual void TestSetup()
 {
     //Start the service if needed
     AppiumServer.Start(TestEnvironmentParameters);
     //Set user provided options.
     MobileTestContext.Set(Constants.AppiumAdditionalOptionsKey, AdditionalCapabilities);
     Capabilities = new DriverCapabilities(TestEnvironmentParameters);
     //Merge user provided options to existing default capabilities.
     Capabilities.MergeCapabilities(MobileTestContext.Get <AdditionalDriverOptions>(Constants.AppiumAdditionalOptionsKey, false));
     // Write Runsettings to log file
     TestLogs.WriteLogSection("Original Test Run Parameters", () => TestLogs.Write(this.TestEnvironmentParameters.ToString()));
     MobileDriver.Initialize(Capabilities);
     //Write device configuration to log file
     TestLogs.WriteLogSection("DUT Configuration", () => TestLogs.Write(MobileDriver.Instance.Capabilities.ToString()));
     //Capture enviroment parameters for all futures uses.
     MobileTestContext.Set(Constants.TestEnvironmentKey, TestEnvironmentParameters);
     TestLogs.AddSection($"Test {TestContext.CurrentContext.Test.Name} Starts");
 }