Thanks. I discovered that workaround in the archives, but it's a real nuisance
because that means I have to create a new test page for every call. I'm using
webservices (microsoft's webservice.htc) and asynchronous calls. I want to
actually call back into the web service (not mockobject) because I specifically
want to test the web service.
I saw a post dated back to 2001 that had someone who dealt with a similar
problem. They had changed the core jsUnit and requested the changes be rolled
into the release but so far as I could tell they weren't. It was regarding
putting in a retry count for the test methods so they would be rerun until they
returned a 0 or null--basically the same idea you've done for setUpPage, but
applied to the test methods as well.
Thanks,
Joel Shellman
> -----Original Message-----
> From: Curt Arnold
> Sent: Wednesday, January 29, 2003 6:24 PM
> To: jsunit@yahoogroups.com
> Subject: Re: [jsunit] Asynchronous testing: calling into
> methods with callbacks
>
>
> joelshellman wrote:
> > I want to call into a library that uses callbacks. So I want a test
> > that does:
> >
> > function testMyMethod() {
> > myMethod(useThisCallback);
> > }
> > function useThisCallback(myData) {
> > assertTrue("Expected some data", "some data", myData.value); }
> >
> > I just tried this and of course it doesn't work. It succeeds
> > completely ignoring whatever the callback method does. How
> can I make
> > this work?
>
> /jsunit/tests/jsUnitTestLoadData.html and
> jsUnitTestLoadStaff.html are
> tests that require an asynchronous load of test documents before the
> body of the test can run. Basically start your callback in setUpPage
> and when all the callbacks are finished set setUpPageStatus to
> "complete" and the body of the test will run. If the status is not
> changed before the page timeout, the test will fail.
>
> So it would be something like:
>
> var setUpPageStatus;
> var data;
>
> function setUpPage()
> {
> setUpPageStatus = 'running';
> myMethod(useThisCallback);
> }
>
> function useThisCallback(myData)
> {
> if (setUpPageStatus == 'running') {
> data = myData.value;
> setUpPageStatus = 'complete';
> }
> }
>
> function testMyMethod()
> {
> assertTrue("Expected some data", "some data", data);
> }
>
>
>
>
>
>
>
> To unsubscribe from this group, send an email to:
> jsunit-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>