Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update:</strong> Modified the build script to download content_shell. Also updated the path to content_shell in the hop task <code>createUnitTestTask()</code>.</p> <hr> <p>I use the <a href="http://pub.dartlang.org/packages/hop" rel="nofollow">hop pub package</a> to do headless testing for drone. You can refer to the <a href="https://github.com/scribeGriff/simplot" rel="nofollow">simplot</a> library for a relatively simple example. But the steps are basically to add the following to your <code>pubspec.yaml</code> as developer dependencies:</p> <pre><code>hop: '&gt;=0.27.0' unittest: '&gt;=0.9.0 &lt;0.10.0' </code></pre> <p>Create a tool directory in your project root and add a file <code>hop_runner.dart</code>. Mine looks something like this:</p> <pre><code>library dumprendertree; import 'package:hop/hop.dart'; import 'dart:io'; import 'dart:async'; main(List&lt;String&gt; args) { addTask('test', createUnitTestTask()); runHop(args); } Task createUnitTestTask() { return new Task((TaskContext tcontext) { tcontext.info("Running Unit Tests...."); var result = Process.run('./content_shell', ['--dump-render-tree','test/simplot_tests.html']) .then((ProcessResult process) { tcontext.info(process.stdout); }); return result; }); } </code></pre> <p>You can see where it is calling my <code>simplot_tests.html</code> file in the test directory.</p> <p>Then my drone script is:</p> <pre><code>$DART_SDK/../chromium/download_contentshell.sh unzip content_shell-linux-x64-release.zip mv drt*/* . pub get sudo start xvfb dart --checked tool/hop_runner.dart test </code></pre> <p>The <code>simplot_tests.html</code> file looks like the following:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Unit Tests for Simplot Library&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript" src="packages/unittest/test_controller.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="packages/browser/dart.js"&gt;&lt;/script&gt; &lt;script type="application/dart" src="simplot_tests.dart"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And finally, the dart file looks something like this:</p> <pre><code>import 'package:simplot/simplot.dart'; import 'package:unittest/unittest.dart'; import 'package:unittest/html_enhanced_config.dart'; import 'dart:html'; import 'dart:math'; part 'tests/logarithmic_tests.dart'; part 'tests/time_stamp_tests.dart'; part 'tests/axis_configure_tests.dart'; part 'tests/create_single_plot.dart'; part 'tests/create_multiple_plots.dart'; part '../lib/src/axis_config.dart'; void main() { print('Running unit tests for simplot library.'); useHtmlEnhancedConfiguration(); group('All Tests:', (){ test('test of logarithmic functions', () =&gt; logarithmicTests()); test('test of time stamp', () =&gt; timeStampTests()); test('test of axis configuration', () =&gt; axisConfigTests()); test('test of creating a single plot', () =&gt; createSinglePlot()); test('test of creating multiple plots', () =&gt; createMultiplePlots()); }); } </code></pre> <p>Hopefully, that should get you started.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload