Xamarin.UITest REPL connection canceled

I am starting automatic testing of the user interface using Xamarin.UITest in Xamarin Studio. I am using the main project CreditCardValidatordefined by Xamarin. My tests work as expected, but when I try to add a line app.Repl();to query the user interface and enter a command tree(or any other for that matter), I keep getting the error:

App has been initialized to the 'app' variable.
Exit REPL with ctrl-c or see help for more commands.

>>> tree                                                                        
Execution failed with exception: System.Net.WebException: Error: 
ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) <0x3acc998 + 0x0017b> in <filename unknown>:0 
at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) <0x3aca8f8 + 0x004b7> in <filename unknown>:0 
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) <0x3acdbe8 + 0x00187> in <filename unknown>:0 
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (IAsyncResult iar, System.Func`2 endFunction, System.Action`1 endAction,     System.Threading.Tasks.Task`1 promise, Boolean requiresSynchronization) <0x1944280 + 0x00069> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x18aa010 + 0x00035> in <filename unknown>:0 
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x18a7830 + 0x000b7> in <filename unknown>:0 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x18a7790 + 0x00087> in <filename unknown>:0 
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x18a7740 + 0x0003f> in <filename unknown>:0 
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () <0x18a8040 + 0x00024> in <filename unknown>:0 
at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () <0x3abbe30 + 0x00df3> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
at Xamarin.UITest.Shared.Http.HttpClient.Request (System.String method, System.String endpoint, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) <0x3aadc68 + 0x0040f> in <filename unknown>:0 
at Xamarin.UITest.Shared.Http.HttpClient.Get (System.String endpoint, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) <0x3aadc18 + 0x0003b> in <filename unknown>:0 
at Xamarin.UITest.Android.AndroidGestures.Dump () <0x3aadb18 + 0x00053> in <filename unknown>:0 
at Xamarin.UITest.Utils.TreePrintHelper.PrintTree (ITreePrinter treePrinter) <0x3aada28 + 0x0002a> in <filename unknown>:0 
at Xamarin.UITest.Queries.AppPrintHelper.Tree (Nullable`1 console) <0x3aad950 + 0x0008b> in <filename unknown>:0 
at <InteractiveExpressionClass>.Host (System.Object& $retval) <0x3aad830 + 0x00047> in <filename unknown>:0 
at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) <0x2ede1b0 + 0x0008f> in <filename unknown>:0 
at Xamarin.UITest.Repl.Evaluation.MonoCSharpReplEngine.Evaluate (System.String line) <0x2ede0a0 + 0x00057> in <filename unknown>:0 
at Xamarin.UITest.Repl.Repl.ReplFacade.RunCode (System.String code) <0x2edde88 + 0x00063> in <filename unknown>:0 
at Xamarin.UITest.Repl.PromptHandler.PrintTree () <0x3aa4e50 + 0x0001f> in <filename unknown>:0 
at Xamarin.UITest.Repl.PromptHandler.HandleInput (ConsoleKeyInfo key) <0x3a38520 + 0x001da> in <filename unknown>:0 
at Xamarin.UITest.Repl.Program.Main (System.String[] args) <0x71def8 + 0x003ef> in <filename unknown>:0 
Press any key to exit.

I added permission INTERNETin the application, and the tests themselves went fine. Code for tests:

public class RecorderTest
{
    public IApp app;
    [SetUp]
    public void Setup()
    {
        app = ConfigureApp.Android.Debug().ApkFile(<path/to/apk/>).StartApp();
    }

    [Test]
    public void CreditCardNumberTooShortError()
    {
        //app.Repl();
        app.Tap(x => x.Id("creditCardNumberText"));
        app.Screenshot("Tapped on view with class: AppCompatEditText");
        app.EnterText(x => x.Id("creditCardNumberText"), "1234");
        app.Tap(x => x.Id("validateButton"));
        app.Screenshot("Tapped on view with class: AppCompatButton");

        AppResult[] result = app.Query(c => c.Class("AppCompatTextView").Text("Credit card number is too short."));
        Assert.IsTrue(result.Any(), "The error message is not being displayed");
}

    [Test]
    public void CreditCardNumberTooLongError()
    {
        app.Repl();
        app.EnterText(x => x.Marked("creditCardNumberText"), new String('9', 17));
        app.Screenshot("Entered Credit card number");
        app.Tap(x => x.Id("validateButton"));
        app.Screenshot("Tapped on view with class: AppCompatButton");

        AppResult[] result = app.Query(c => c.Id("errorMessagesText").Text("Credit card number is too long."));
        Assert.IsTrue(result.Any(), "The error message is not being displayed");
    }

}

I used Xamarin's Calabash Framework, and I can use the command consoleand request the application just fine. Not sure whey does not work with Xamarin.UITest.

Java 1.7, NUnit 2.6.3 Xamarin Studio 6.0.1 ( 9)

+4

Source: https://habr.com/ru/post/1649594/


All Articles