Adding common test cases

1 view
Skip to first unread message

Nicolas Alpi

unread,
Mar 5, 2009, 5:55:10 AM3/5/09
to jShoulda
Hi guys,

First of all, thank you very much for Jshoulda (and btw JsUnitTest).
The integration is just great, and works well.

But I still have a question ...

I have different pages, and when I load the pages, I load the test
file for this particular page.

But I want to share some test beetween different pages.

For exemple on the Jshoulda tutorial, the assertLocalYipiyay is shared
with the context block, but can I have a page called
commno_tests_assertion with all my custom assertions ?

I tried to add a :

JsUnitTest.Unit.Assertions += { .... } but doesn't seems to work.

Obviously if I put my custom assertion on the JsUnitTest file it
works ... but I don't want to touch this file. Juts in case of update.

Any ideas ?

ps : Little typo in the JShoulda tutorial, section Unifying test
runners (new in 1.2), jShoulda.unifyRunners(runners); should be
jShoulda.unifyRunners(runner);

Nic (not the doctor :( one)

Choan Gálvez

unread,
Mar 5, 2009, 12:23:54 PM3/5/09
to jsho...@googlegroups.com
Hi Nic.

On Mar 5, 2009, at 11:55 , Nicolas Alpi wrote:

> For exemple on the Jshoulda tutorial, the assertLocalYipiyay is shared
> with the context block, but can I have a page called
> commno_tests_assertion with all my custom assertions ?
>
> I tried to add a :
>
> JsUnitTest.Unit.Assertions += { .... } but doesn't seems to work.
>
> Obviously if I put my custom assertion on the JsUnitTest file it
> works ... but I don't want to touch this file. Juts in case of update.

You should add your custom assertions to the
`JsUnitTest.Unit.Testcase.prototype`.

An example:

JsUnitTest.Unit.Testcase.prototype.assertCustom = function(expected,
actual, message) {
this.assertEqual(expected, actual, message);
};


> ps : Little typo in the JShoulda tutorial, section Unifying test
> runners (new in 1.2), jShoulda.unifyRunners(runners); should be
> jShoulda.unifyRunners(runner);

Oops, thanks. Fixed now.

--
Choan
<http://choangalvez.nom.es/>

Nicolas Alpi

unread,
Mar 6, 2009, 9:19:49 AM3/6/09
to jShoulda
Thank you very much for the response,

So I now have a common test page with :

Test.Unit.Testcase.prototype.assertLocalYipiyay = function(actual,
msg) {
this.assertEqual('yipiyay', actual, msg);
};


And my asserLocalYipiyay works in every block. Exactly what I needed.

Nic
Reply all
Reply to author
Forward
0 new messages