1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Xamarin.UITest が HttpRequestException で失敗する場合の対処

Posted at

症状

Xamarin.Forms の新規ソリューションを UITest 付きで作成して、すぐに Android 側の UITest を実行してみたところ、

SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request
  ----> System.IO.IOException : Unable to write data to the transport connection: The socket has been shut down.
  ----> System.Net.Sockets.SocketException : The socket has been shut down

という例外が発生して、テストが成功しませんでした。

テンプレで作成されるテストケースは

[Test]
public void WelcomeTextIsDisplayed()
{
    AppResult[] results = app.WaitForElement(c => c.Marked("Welcome to Xamarin.Forms!"));
    app.Screenshot("Welcome screen.");

    Assert.IsTrue(results.Any());
}

というもので、画面に "Welcome to Xamarin.Forms" が表示されたら成功ですが、
そもそもテスト対象アプリが起動せず終了しています。

原因と対処

UITest のプロジェクトが参照している Xamarin.UITest パッケージのバージョンが古い(2.24以下?)と発生するようです。

image.png

パッケージをアップデート(この時点では 2.2.7 になりました)してテストを実行しなおすと、無事アプリが起動してテストが成功するようになりました。

image.png

Visual Studio for Mac 7.7.3 での事でしたが、理由はともかく、いきなり動かんのはおかんむりです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?