Frage

Currently I am developing nodeunit tests and I stumbled upon a problem.

I have a folder named "Unit_tests"

In this folder I have a file "testInitializer.js" which contains 2 methods: init and term.

These methods should be run just once and only at the beginning and the end of all the other tests. Other tests are in separate folders under the root "Unit_tests".

How can I make sure this file is run first.

As of now, it does mostly but in some cases it doesn't. Is there a way in webstorm to make sure it runs first?

Many thanks in advance!

War es hilfreich?

Lösung

As far as I know, this is not possible with only NodeUnit, since it uses an asynchronous approach where the callbacks don't execute in a predictable order. This behavior is by desing, and is supposed to provide a more realistic testing routines and prevent dependencies between tests.

You can however use Grunt JS with the NodeUnit plugin to take full control of your testing process.

You can find a great article on this topic here:
http://markdalgleish.com/2012/09/test-driven-node-js-development-with-grunt/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top