xamarin UI测试-无法加载我指向的本机APK路径 [英] xamarin UI Test - Unable to load the native APK path that I point to
问题描述
我想通过以下代码引用APK的路径,从而在本机android APK上运行REPL UI测试.
I want to run a REPL UI Test on native android APK by referring to the path of the APK with following code.
public void BeforeEachTest()
{
app = ConfigureApp.Android
.ApkFile("C:/app-debug.apk")
.StartApp():
}
public void AppLaunches()
{
app.Repl();
}
但是,在运行测试期间,它将始终像下面这样加载测试,这不是我设置的路径.
But, during running test, it will always load test like below which is not the path that I've set.
从testing \ Xamarin Testing \ AndroidTest \ AndroidTest \ bin \ Debug \ AndroidTest.dll加载测试
Loading tests from testing\Xamarin Testing\AndroidTest\AndroidTest\bin\Debug\AndroidTest.dll
REPL控制台无法打开,并且我的所选APK未被测试,并且没有错误消息,我该怎么办?
the REPL console is not opening and my selected APKis not being test, and there are no error messages, what should I do?
我没有找到任何相关的解决方案.
I have not found any related solution.
我已经安装:NUnit {2.6.4},NUnit3TestAdapter {3.7.0},NUnitTestAdapter {2.0.0}和Xamarin.UITest {2.0.5.1591-dev}
I've installed: NUnit {2.6.4}, NUnit3TestAdapter {3.7.0}, NUnitTestAdapter{2.0.0} and Xamarin.UITest {2.0.5.1591-dev}
推荐答案
您会注意到以下路径中的//语法适用于我的UI测试.您为什么不尝试C://whateverfolderyourapkisin/app-debug.apk.
You will notice the // syntax in the below pathing works for my UI tests. Why dont you try C://whateverfolderyourapkisin/app-debug.apk.
if (platform == Platform.Android)
{
var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
path = path.Substring(6);
path = path.Replace("UITest", "My_AppFolder_PCL\\My_AppFolder_PCL.Droid");
path = path + "/com.mycompany.myapp.apk";
path = path.Replace("\\", "//");
return ConfigureApp
.Android
.EnableLocalScreenshots()
.ApkFile(path)
.StartApp();
}
这篇关于xamarin UI测试-无法加载我指向的本机APK路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!