在Flutter中是否有可能运行由其他编程语言编写的测试代码?

huangapple go评论77阅读模式
英文:

Is it possible to run test code written by other languages in flutter?

问题

我试图使用Appium来自动化我的Web视图应用程序,但是我从Appium导出的代码是用Java编写的。在测试Flutter应用程序时,是否可以使用其他语言编写的测试代码,而不是使用Dart编写的代码?

英文:

I am trying to automate my webview app by using Appium, but code that I exported from Appium is written in java. Is it possible to test flutter app by test code written in other languages, not in dart?

答案1

得分: 1

UPDATE:您可以将Appium与Selenium结合使用。我认为这应该是可行的。请参阅:http://appium.io/docs/en/writing-running-appium/web/mobile-web/

如果测试框架所做的是与浏览器集成或仿真,并操作DOM以进行测试,

如果您的Dart应用程序仅操作DOM以生成Web视图 - 例如,它可以在常规浏览器中运行而无需使用插件,

那么是的,您可以使用这样的工具(如Selenium)来测试Dart应用程序。

这里的一个注意点是,如果您正在使用WebView将应用程序嵌入移动应用程序框架,则这些工具必须能够在移动设备上打开应用程序以访问WebView。

如果您可以为应用程序创建替代基础架构,使其既可以在浏览器中运行,也可以作为移动应用程序中的嵌入式WebView运行,那么所需的测试工具只是简单的Web应用程序测试框架。

如果您可以通过将应用部署到Web服务器并运行测试来获得更快的反馈,而不是将应用打包并推送到连接的设备,那么这通常是一个很好的方法。

这并不消除在WebView中进行测试的必要性,因为嵌入在WebView中的浏览器与桌面浏览器中的功能通常存在差异,但是发现的任何差异都纯粹基于浏览器的功能,而不是您的Dart逻辑中的问题。

英文:

UPDATE: You can use Appium in conjunction with Selenium. I think that should work. See: http://appium.io/docs/en/writing-running-appium/web/mobile-web/

If what the test framework does is to integrate with, or emulate, a browser, and manipulate the DOM in order to test, and

If your Dart application only manipulates the DOM to generate a web view -- e.g., it would work in a regular browser without using plugins,

Then yes, you can use such a tool (like Selenium) to test a Dart app.

The caveat here is, if you are using a WebView to embed your app in a mobile app framework, then these tools will have to have the ability to open an app on a mobile device to access the WebView.

If you can create an alternate scaffolding for your application, such that it can also run in a browser, not only as an embedded WebView in a mobile app, then the tools needed to test it are only simple web app testing frameworks.

This is generally a good approach if you can get faster feedback deploying to a web server and running your tests, than packaging the app and pushing it to a connected device.

It doesn't obviate the need to test in the WebView as there are often differences between browser capabilities as embedded in a WebView versus in a desktop browser, but any differences found would be purely based on the capabilities of the browser, as opposed to problems in your Dart logic.

huangapple
  • 本文由 发表于 2020年8月21日 22:14:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/63524541.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定