G
Garrett Smith
David said:[...]
I think not.
Those could all be improved by automation. Significantly
Please don't make me click through to every example and don't make
complicated test cases (like an functional/example page that has every
usage of the property/method).
No clue what that means.
By functional test, here, I am referring to here is a static demo page,
like any of the Hixie or Juriy tests.
Another sort of functional test is use-case functionality. Selenium is
useful for that.
Clicking each example is tiresome and doesn't give a comprehensive view
of what works and what fails.
A functional test that tries to test everything about one specific
property is worse because it is not focused on one thing.
Unit tests are the well-suited for testing browser features and dom
features because each aspect can be tested.
insertBefore suite might contain: testReturnsNode, testRefNodeNull,
testHeirarchyRequestErr, testWrongDocumentErr, testNoModificationErr,
testNotFoundErr.
A unit test page can do those things and separate out the test cases to
test functions, where each function tests one specific thing, using
maybe 4-8 lines of code for each test function.
Or that.
Specifications should provide guidance for the outcome of assertions and
also can help outline an API.
For example, any of the DOM APIs could be tested, ECMA specs can be
tested. Such tests would be valuable to me. I believe they could
potentially contribute usefull to the w3c APIs. I doubt that anyone in
the w3c would be able to see it. I might have had better luck if I had
shown them actual test cases. That takes a bit of time to set up. You
can see my input to that here:
http://lists.w3.org/Archives/Public/www-dom/2009JulSep/0013.html
I'm no sure what the status is; I can't follow up because I was banned
from the list.
I don't need to write one. I have what I need for now.
That's what Hixie said. I still think he's missing something valuable in
that. He doesn't (or didn't) see value in it. His acid tests, to me, are
not valuable tools that I can refer to to see what works where, etc. His
functional tests require a click through to each one are not even
indexed that well. Having to click through does not provide a
comprehensive view of what fails and what passes because you have to
click through to each one, and in each browser, to see those results.
What is valuable for me, is to see the appendChild method, see where it
fails, and see an example of it.
You are getting way ahead of me.
For example, say you ahve an XHR adapter. The adapter makes a call to
the server, and when the response comes, you need to verify that response.
A test case wants to test the success of a response.
To test that, the test case gets a connection. Opens, sends, and then
*waits* for the response. The `success` callback fires asynchronously;
it cannot be tested until the xhr is complete. The problem is, we don't
know when that will happen.
What YUI Test provides is a `wait` method. `wait` takes two arguments:
callback, and timeout millis. So what you can do is to wait for a while.
The assertions that verify the message of the ajax call are performed in
the `wait` callback.
test case:-
this.wait(function(){
Assert.areSame("a", xhr.responseText);
}, 4000);
I would like a `waitForCondition` method, so I could, say:-
this.waitForCondition(function(){
Assert.areSame("a", xhr.responseText);
}, condition);
function condition(){
xhr.complete == true;
}
I don't really like that order, but it is consistent with the `wait`
approach.
Also, I don't like how most x unit frameworks have expected result
first. TestNG (Java) is switched, which makes sense, but inconsistent.
Whatever YUI is doing with their stuff is irrelevant.
If you try the test runner, you might get a feel for the API and about
testing. You'll find what you don't like and maybe you might find things
that are valuable in it. It is a lot better than JS Unit.
The problems in the design of the YUI Test are solvable; it's not like
he painted himself into a corner.