testing - 如何测试为客户端和服务器端制作的 Dart 包?

标签 testing dart

我正在制作一个同时提供客户端和服务器端代码的库。在做测试的时候,我想测试双方的互动。

到目前为止我至少有这个测试:

服务器端:

@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

readmehttps://github.com/dart-lang/test/tree/master/doc 中的文档提供有关如何配置测试运行程序的大量详细信息。

关于testing - 如何测试为客户端和服务器端制作的 Dart 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39681618/

相关文章:

testing - XCode9:XCUITest 给出 Runner UIAccessibility 错误

android - 与选定的用户一起测试 Android 应用

testing - Coffeescript 测试捕获 ajax 调用

python - 单元测试和多个模块的 ImportError

python-2.7 - 机器人框架中具有多个 Action 的 If-Condition

dart - 如何在double和int之间强制转换num类型

dart - 从状态类外部更改 Flutter 小部件的状态

flutter - Flutter-如何添加搜索栏以在列表中搜索

flutter - 如何摆脱Flutter/dart中 'Future<dynamic>'的实例?

firebase - 如何基于数组中的多个值过滤快照流?