Nico Rodsevich Nico Rodsevich - 1 year ago 98
Dart Question

How to test Dart's package made for both client and server side?

I'm making a library that provides both client & server side code. When making the tests, I would like to test the interactions from both sides.

So far I have at least this tests:

Server side:

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

Cliente side:

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

What should I do to have all the tests ran with a single command? Is it possible?

Answer Source

As stated in the docs provided by G√ľnter, create dart_test.yaml in the package's root:


#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 it takes long (generally on opening the browser) you could add to the same config file:

timeout: none #or i.e., 1m 30s

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

- vm
- content-shell

If this doesn't work, you could save the hours it took me figuring out what the heck happened by running:

pub cache repair

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download