Using JS Unit Mock Timeout

115 visualizzazioni
Passa al primo messaggio da leggere

Karl O'Keeffe

da leggere,
1 lug 2009, 12:16:0201/07/09
a JsTestDriver
Hi all,

Many of my current tests use the JS Unit Mock Timeout to provide a
method for simulating time (useful for ajax requests, time limited use
interaction, etc).

See this Google Testing Blog post for more details:
http://googletesting.blogspot.com/2007/03/javascript-simulating-time-in-jsunit.html


At the moment JS Test Driver does not work with the JS Unit Mock
Timeout (jsUnitMockTimeout.js) file. It uses timeouts as part of it's
control mechanism, and these fail to work when we include
jsUnitMockTimeout.js, as it overwrites the setTimeout (and other)
methods with it's own mocks.

I'm not sure of the best way to fix this, but I was thinking that JS
Test Driver could make it's own copies of the setTimeout,
clearTimeout, setInterval, clearInterval methods and use those at all
times. Then the mock timeout framework can be included without any
problems.

What are peoples thoughts on this?

Karl O'Keeffe

da leggere,
1 lug 2009, 12:47:0701/07/09
a JsTestDriver
While waiting for peoples thoughts, I've hacked together a version of
JS Test Driver that uses it's own copies of setTimeout and co.

You can see the details and download it from my blog:
http://monket.net/blog/2009/07/jsunit-mock-timeouts-and-js-test-driver/

Jeremie Lenfant-engelmann

da leggere,
1 lug 2009, 13:07:0801/07/09
a js-test...@googlegroups.com
Hi Karl,

I think it's a great idea, I would just do something like:

jstestdriver.setTimeout = setTimeout;
jstestdriver.clearTimeout = clearTimeout;
etc...

Is it what you tried?
--
Jeremie

Karl O'Keeffe

da leggere,
2 lug 2009, 01:55:1502/07/09
a JsTestDriver
> I think it's a great idea, I would just do something like:
>
> jstestdriver.setTimeout = setTimeout;
> jstestdriver.clearTimeout = clearTimeout;
> etc...

Yep that's exactly what I did. You also need to make sure that the js
test driver jQuery uses the same timeouts.

I just hacked these changes into the already compressed javascript as
I didn't have time to work out the build process.

I was hoping you would be able to incorporate them?

Jeremie Lenfant-engelmann

da leggere,
2 lug 2009, 12:58:0802/07/09
a js-test...@googlegroups.com
Yes I will !

Thanks Karl.
--
Jeremie

Jeremie Lenfant-engelmann

da leggere,
7 lug 2009, 11:33:3307/07/09
a js-test...@googlegroups.com
Hi Karl,

Just to let you know that I have made the change, you should be able
to sync to HEAD build the jar and everything should work.
--
Jeremie
Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi