我正在制作一个同时提供客户端和服务器端代码的库。在做测试的时候,我想测试双方的互动。
到目前为止我至少有这个测试:
服务器端:
@TestOn("vm")
import "package:test/test.dart";
import "dart:io";
//...
void main() {
HttpServer server = HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 4040)
//.then()...
客户端:
@TestOn("content-shell")
import "package:test/test.dart";
import "dart:html";
//...
void main(){
//Interact with server at 4040
我应该怎么做才能用一个命令运行所有测试?可能吗?
最佳答案
@TestOn("content-shell")
在我看来没有多大意义,除非该测试不应在其他浏览器中运行。请改用浏览器
。
如果没有 @TestOn()
(默认),测试将在任何平台上运行。如果您想限制测试的运行位置,请仅添加 @TestOn(...)
。
使用单个命令运行浏览器测试和服务器测试
pub run test -pvm -pdartium -pchrome -pfirefox -pie -pblink
或者更短一些
pub run test -pvm,dartium,chrome,firefox,ie,blink
readme和 https://github.com/dart-lang/test/tree/master/doc 中的文档提供有关如何配置测试运行程序的大量详细信息。
关于testing - 如何测试为客户端和服务器端制作的 Dart 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39681618/