How to check Dart package made both on client side and server side?

I am making a library that provides both client and server code. When conducting the tests, I would like to check the interaction on both sides.

So far I have at least these tests:

Server side:

@TestOn("vm") import "package:test/test.dart"; import "dart:io"; //... void main() { HttpServer server = HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 4040) //.then()... 

Client side:

 @TestOn("content-shell") import "package:test/test.dart"; import "dart:html"; //... void main(){ //Interact with server at 4040 

What to do so that all tests are performed with a single command? Is it possible?

+5
source share
2 answers

As indicated in the docs provided by Günter, create dart_test.yaml in the root of the package:

 #dart_test.yaml #run 2 test suites at the same time (I guess, that in 2 different cores) concurrency: 2 

Now run

pub run test test / server.dart test / client.dart -pvm, content-shell

If this takes a long time (usually when opening a browser), you can add to the same configuration file:

 timeout: none #or ie, 1m 30s 

You can also save part of the -pvm command, the content-shell command, by running the configuration file:

 platforms: - vm - content-shell 

If this does not work, you can save the time it took me to figure out what happened by doing:

restore folder cache

+2
source

@TestOn("content-shell") does not make much sense, in my opinion, except when this test should not be run in other browsers. Use browser instead.

Without @TestOn() (by default), tests will run on any platform. Add @TestOn(...) only if you want to limit where the test runs.

To run browser tests and test the server with a single command, use

 pub run test -pvm -pdartium -pchrome -pfirefox -pie -pblink 

or a little shorter

 pub run test -pvm,dartium,chrome,firefox,ie,blink 

readme and docs at https://github.com/dart-lang/test/tree/master/doc provide detailed information on how to set up a test runner.

+2
source

All Articles