Tags related to tag test
Tuesday, July 3. 2007
More Moz Repl goodness
In my previous entry, I described how one could set up selenium to runs tests from emacs, via the Moz REPL. The most painful part of all of that is setting up the REPL to run. After every firefox startup, you have to manually go to tools menu, and manually select 'MozLab' and then 'Start REPL'. YUCK.
It would be nice if you could somehow automatically run javascript on Firefox startup.
Enter UserChrome.js. With a little more polish, some documentation, and something more then a MozillaZine forum posting for a website; this little extension is poised to become the new GreaseMonkey. It will be the GreaseMonkey for the hard core.
Once you have installed the extension, you can now run Javascript on the creation of every new Mozilla window (even sub windows like prefs, downloads, etc.) or just the main window. From this point, it is almost painless to start the REPL:
// Anonymous function application to
(function(){
var repl = Components.classes["@hyperstruct.net/mozlab/mozrepl;1"].getService(Components.interfaces.nsIMozRepl);
if (repl && (!repl.isActive()))
{
repl.start(4242);
}
})();
This gives you a good example of how to interact with other Firefox plugins/addons through Javascript.
Monday, June 25. 2007
Automated Web Developer Tests using Selenium, Emacs, and MozRepl
Enter Selenium IDE. The Selenium IDE provides you with a method to record and execute automated tests of your website. It is easy to use, and hella cool. It can test things like the existence of an element, the text contained inside of an element, its width, height, position, etc. Using selenium, you can build yourself unit tests. This is especially useful and powerful if you happen to be one of the unlucky bastards faced with writing code in JSTL, SMARTY, or some other templating-language-that-needs-to-die. Now you finally have unit tests.
Using Selenium, the testing process is a little more automated. More importantly, you can build a series of regression tests, to ensure the stability of your web application.
There is another piece of the web-development puzzle here, and that is the Moz Repl. An REPL is a Read Eval Print Loop, basically an interactive command interpreter that you can feed commands to, and experiment with. the Moz REPL is a javascript version, that lets you inspect and modify any Javascript object in the browser. This REPL is telnet enabled, in fact, there is even a way to make Emacs talk to this REPL, so you can poke around the browser from within your text editor. This is amazingly powerful in two regards:
- you can script your browser from emacs
- you can edit code inside emacs, and send it right to the javascript interpreter for testing, and evn install it on the current page
So the final piece of the puzzle is something I call Selenemacs. It is a global emacs minor mode, in conjunction with some simple javascript that will script selenium, and provide you with feedback on whether or not its tests pass or fail.
Update 2007-07-09: new versions (Version 0.2) added
Here are the two files:
Here is how you use them:
First, download the MozREPL and Selenium IDE extensions for firefox
Edit selenemacs.el to make sure that the variable selenemacs-js-file points to selenemacs.js
Enable the MozRepl (Tools->MozLab->StartREPL)
Load up selenemacs.el inside emacs (load-file "path/to/selenemacs.el") works
Enable the minor mode selenemacs-minor-mode
Record your test in SeleniumIDE
Use the emacs command selenemacs-execute-test to launch the test, its shortcut is C-c C-s C-e
Emacs tells you if the test passed or failed.
The idea here is that you write your test, and stop using your eyes to test the results of your coding to the browser, but instead use Selenium. This is especially good if you are doing multi-stage and repetitive like testing logins, searches, etc. You can code and test right inside emacs, and only have to switch to the browser to verify that your tests actually passed.
These files also show an interesting way to script mozilla through emacs. The next step of course is to get emacs to start interacting with Firebug.
Wednesday, November 3. 2004
I am Wiki!
Wednesday, April 21. 2004
Morality?
When I answered the questions, I wasn't afraid to be personally revolted by the act of the family eating their dead cat, but did not claim that they should be stopped for it. I did draw the line at the SisterFisting.
But when I saw how other people moralize (or, rather, no not moralize), It got me thinking, and being the social animal that I am, made me question my own answers. So, here is my revised moral compass:
0.10 0.00 and 1.00.
That's right, my universalizing is at 1.00. Again, I am bothered by a few actions, less this time (cat eating, SisterFisting), but no not go so far as to say anything is universally wrong, except for the SisterFisting.
This coincides with my re-reading of Starship Troopers ... (read more for pseudo-scientific ranting about math and morality)
One of the central ideas of Starship Troopers is the idea that morality can be scientifically examined, and codified. So that we can make statements about morality in the same way we can make statements about Number theory or Chemistry.
Now, putting aside the fact that if "Morality Theory" is sufficiently powerful, we can Goedelize the motherfucker, here is a thought I had whilst in a shower.
Take a real number between 0 and 1, call it H for Harm. This is the amount of damage to one person that this action would cause. 1 is equivalent to killing them. Actions that make a permanent effect (maiming/mutilation/psychological torture) would rate round 0.75. etc. (of course, there is no hard and fast rules here, or no real way to figure that number out beyond a look-up table of sorts.
Now, take antihero number, this is the number of individuals who would be harmed. Call this x.
Thus Morality is Hx. Hitler is a bad man, and Gassed 6 million jews. His Morality is 6,000,000.
Sending spam has a very small H, something like 0.00001 I suspect. But, if a spammer sends out 6 million emails, it would be equivalent to killing 60 people.
I am not sure if that means that I hit the mark, or i am WAY off.
Tuesday, April 13. 2004
Trackback Test 2
Trackback testing Some other guys blog now





