diff --git a/lib/unit.js b/lib/unit.js index 6a0aa7c..ed7c432 100644 --- a/lib/unit.js +++ b/lib/unit.js @@ -220,21 +220,22 @@ exports.init = function (opt) { udf.setup(function (ctx) { var listener = new Listener(getEngine()); if (aMeta.script) { - getEngine().exec(aMeta.script, function (err, result) { - listener.assert(test); - try { - udf.test(test, err, result, ctx); - } - catch (e) { - test.ok(false, 'Got Exception in tester: ' + util.inspect(e, false, null)); - } - udf.tearDown(function () { - test.done(); - cb(); - }, ctx); + getEngine().execute(aMeta.script, {context: {foo:'bar'}}, function(emitter) { + emitter.on('end', function (err, result) { + listener.assert(test); + try { + udf.test(test, err, result, ctx); + } + catch (e) { + test.ok(false, 'Got Exception in tester: ' + util.inspect(e, false, null)); + } + udf.tearDown(function () { + test.done(); + cb(); + }, ctx); + }); }); - } - else if (aMeta.request) { + }else if (aMeta.request) { getConsole().app.listen(port, function () { var options = { host:'localhost',