Xamarin.UITest REPL连接被拒绝

时间:2016-07-29 22:47:56

标签: c# xamarin.android

我正在使用Xamarin Studio中的Xamarin.UITest进行UI自动化测试。我正在使用Xamarin提供的基本CreditCardValidator项目。我的测试按预期工作,但是当我尝试添加行app.Repl();来查询UI并输入tree命令(或任何其他此类命令)时,我不断收到错误:

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.

我在应用中添加了INTERNET权限,测试本身运行正常。测试代码是:

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");
    }

}

我也使用了Xamarin的 Calabash 框架,我可以使用console命令并查询应用程序就好了。不确定乳清这是不是与Xamarin.UITest一起使用。

我正在运行Java 1.7,NUnit 2.6.3和Xamarin Studio 6.0.1(build 9)

0 个答案:

没有答案