コード例 #1
0
 static Program()
 {
     AppInitializer.Initialize();
 }
コード例 #2
0
ファイル: BaseTests.cs プロジェクト: Sleitter27/MetiendoMano
 public void BeforeEachTest()
 {
     App = AppInitializer.StartApp(platform);
 }
コード例 #3
0
        [Timeout(500000)]         // Adjust this timeout based on average test run duration
        public async Task RunBenchmarks()
        {
            Run("Benchmarks.Shared.Controls.BenchmarkDotNetTestsPage");

            IAppQuery AllQuery(IAppQuery query)
            // .All() is not yet supported for wasm.
            => AppInitializer.GetLocalPlatform() == Platform.Browser ? query : query.All();

            var runButton        = new QueryEx(q => AllQuery(q).Marked("runButton"));
            var runStatus        = new QueryEx(q => AllQuery(q).Marked("runStatus"));
            var runCount         = new QueryEx(q => AllQuery(q).Marked("runCount"));
            var benchmarkControl = new QueryEx(q => AllQuery(q).Marked("benchmarkControl"));

            bool IsTestExecutionDone()
            {
                try
                {
                    var text = runStatus.GetDependencyPropertyValue("Text")?.ToString();
                    var r2   = text?.Equals("Finished", StringComparison.OrdinalIgnoreCase) ?? false;

                    Console.WriteLine($"IsTestExecutionDone: {text} {r2}");

                    return(r2);
                }
                catch
                {
                    Console.WriteLine("Skip IsTestExecutionDone");

                    // Skip exceptions as they may be timeouts
                    return(false);
                }
            }

            _app.WaitForElement(runButton);

            TakeScreenshot("Begin", ignoreInSnapshotCompare: true);

            _app.FastTap(runButton);

            var lastChange = DateTimeOffset.Now;
            var lastValue  = "";

            while (DateTimeOffset.Now - lastChange < TestRunTimeout)
            {
                try
                {
                    if (IsTestExecutionDone())
                    {
                        break;
                    }

                    var newValue = runCount.GetDependencyPropertyValue("Text")?.ToString();

                    if (lastValue != newValue)
                    {
                        Console.WriteLine($"Loop: Test changed now:{DateTimeOffset.Now} lastChange: {lastChange}");

                        lastChange = DateTimeOffset.Now;
                        TakeScreenshot($"Run {newValue}", ignoreInSnapshotCompare: true);
                    }
                }
                catch (Exception e)
                {
                    // Skip exceptions as they may be timeouts
                }

                await Task.Delay(TimeSpan.FromSeconds(.5));

                Console.WriteLine($"Loop: now:{DateTimeOffset.Now} lastChange: {lastChange}");
            }

            if (!IsTestExecutionDone())
            {
                Assert.Fail("A test run timed out");
            }

            var finalFile = ArchiveResults(benchmarkControl);

            TestContext.AddTestAttachment(finalFile, "benchmark-results.zip");

            TakeScreenshot("Runtime Tests Results", ignoreInSnapshotCompare: true);
        }
コード例 #4
0
 public AppUser()
 {
     Platform = GetSelectedPlatform();
     App      = AppInitializer.StartApp(Platform);
 }
コード例 #5
0
 public void BeforeEachTest()
 //sample note
 {
     app = AppInitializer.StartApp(platform);
 }
コード例 #6
0
 public void BeforeEachTest()
 {
     app = AppInitializer.StartApp(platform, _path);
 }
コード例 #7
0
        [Timeout(700000)]         // Adjust this timeout based on average test run duration
        public async Task RunRuntimeTests()
        {
            Run("SamplesApp.Samples.UnitTests.UnitTestsPage");

            IAppQuery AllQuery(IAppQuery query)
            // .All() is not yet supported for wasm.
            => AppInitializer.GetLocalPlatform() == Platform.Browser ? query : query.All();

            var runButton        = new QueryEx(q => AllQuery(q).Marked("runButton"));
            var failedTestsCount = new QueryEx(q => AllQuery(q).Marked("failedTestCount"));
            var failedTests      = new QueryEx(q => AllQuery(q).Marked("failedTests"));
            var runningState     = new QueryEx(q => AllQuery(q).Marked("runningState"));
            var runTestCount     = new QueryEx(q => AllQuery(q).Marked("runTestCount"));

            bool IsTestExecutionDone()
            => runningState.GetDependencyPropertyValue("Text")?.ToString().Equals("Finished", StringComparison.OrdinalIgnoreCase) ?? false;

            _app.WaitForElement(runButton);

            _app.FastTap(runButton);

            var lastChange = DateTimeOffset.Now;
            var lastValue  = "";

            while (DateTimeOffset.Now - lastChange < TestRunTimeout)
            {
                var newValue = runTestCount.GetDependencyPropertyValue("Text")?.ToString();

                if (lastValue != newValue)
                {
                    lastChange = DateTimeOffset.Now;
                }

                await Task.Delay(TimeSpan.FromSeconds(.5));

                if (IsTestExecutionDone())
                {
                    break;
                }
            }

            if (!IsTestExecutionDone())
            {
                Assert.Fail("A test run timed out");
            }

            var count = failedTestsCount.GetDependencyPropertyValue("Text").ToString();

            if (count != "0")
            {
                var tests = failedTests.GetDependencyPropertyValue <string>("Text")
                            .Split(new char[] { '§' }, StringSplitOptions.RemoveEmptyEntries)
                            .Select((x, i) => $"\t{i + 1}. {x}\n")
                            .ToArray();

                var details = _app.Marked("failedTestDetails").GetDependencyPropertyValue("Text");

                Assert.Fail(
                    $"{tests.Length} unit test(s) failed.\n\tFailing Tests:\n{string.Join("", tests)}\n\n---\n\tDetails:\n{details}");
            }

            TakeScreenshot("Runtime Tests Results", ignoreInSnapshotCompare: true);
        }
コード例 #8
0
 private ScreenshotInfo CurrentTestTakeScreenShot(string name) =>
 // Screenshot taking for this fixture is disabled on Android because of the
 // presence of the status bar when native popups are opened, adding the clock
 // (that is always changing :)).
 TakeScreenshot(name, ignoreInSnapshotCompare: AppInitializer.GetLocalPlatform() == Platform.Android);
コード例 #9
0
 public StepsBase(Platform platform)
 {
     app = AppInitializer.StartApp(platform);
 }
コード例 #10
0
 public static void Initialize()
 {
     AppInitializer.Initialize();
     AppSession.Register(CombineAppSession.Instance);
 }
コード例 #11
0
 public static void Cleanup()
 {
     AppInitializer.Cleanup();
 }
コード例 #12
0
 public static void Initialize(TestContext context)
 {
     AppInitializer.Initialize();
 }