Hi all:
Does anyone know the syntax for setUp and tearDown functions/methods for JsTestdriver? On their website they claim to be able to define it, but I can't get it right.
Thanks.
Hi all:
Does anyone know the syntax for setUp and tearDown functions/methods for JsTestdriver? On their website they claim to be able to define it, but I can't get it right.
Thanks.
I download the code and greped for "setUp" and discovered the following:
javascript/TestCaseBuilder.js: if (typeof testCaseClass.prototype.setUp == 'undefined') {
javascript/TestCaseBuilder.js: testCaseClass.prototype.setUp = function() {};
javascript/plugins/TestRunnerPlugin.js: if (testCaseInstance.setUp) {
javascript/plugins/TestRunnerPlugin.js: testCaseInstance.setUp();
And similar for "tearDown":
javascript/TestCaseBuilder.js: if (typeof testCaseClass.prototype.tearDown == 'undefined') {
javascript/TestCaseBuilder.js: testCaseClass.prototype.tearDown = function() {};
javascript/plugins/TestRunnerPlugin.js: if (testCaseInstance.tearDown) {
javascript/plugins/TestRunnerPlugin.js: testCaseInstance.tearDown();
So it seems that the setUp and tearDown functions are defined just like any other test function except that their name is 'setUp' and 'tearDown'. Their example was:
GreeterTest = TestCase("GreeterTest");
GreeterTest.prototype.testGreet = function() {
var greeter = new myapp.Greeter();
assertEquals("Hello World!", greeter.greet("World"));
};
And not knowing what level of js programmer you are, if you are not familiar with the 'prototype' key (because it has a very special meaning in javascript), then check out these YUI vids
However, that seems like a really bad design decision because this way you can define only one setUp and tearDown function, so I feel like there's got to be a better way, but that's the best I could find.
And I agree that their documentation description of setUp, tearDown does not seem most intuitive.
And in case you are looking for other options as well, I am just starting to learn Selenium and am finding it satisfactory (though its docs are also lacking a little I think)