Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write multiple unittests in dart in multiple files?

Tags:

dart

I am writing some Dart library and want to have it unittested. I created directory test and want to put my tests in here. Because I am going to have a lot of tests, I want to have them separated to multiple files. My questions is, what is the Dart convention, how to do that. I want to have my tests easily run all, however, I also want to be able to run just one file of tests.

What are your suggestions?

like image 950
Samuel Hapak Avatar asked Aug 26 '13 15:08

Samuel Hapak


1 Answers

There is a tool that does exactly that, Dart Test Runner. An excerpt from that page:

Dart Test Runner will automatically detect and run all the tests in your Dart project in the correct environment (VM or Browser).

It detects any test writen in a file suffixed with _test.dart where your test code is inside a main() function. It doesn't have any problem detecting and running unittest tests.

It's pretty easy to install it and run it. Just two commands:

$ pub global activate test_runner
$ pub global run test_runner

For more options, please check Dart Test Runner page.

like image 88
rchavarria Avatar answered Sep 21 '22 10:09

rchavarria