Скачать 3.51 Mb.
One button must test all aspects of every module, and one top-level AllTests command must test all modules. Our survey of techniques here challenges rambunctious web projects to minimize their language diversity. Ideally, only one language should host all tests. But our survey showed how different web layers can require tests in different languages.
result = system("kjscmd myDomTests.js")
The patterns of failures in these “shelled tests”, and their interactions with your editors, will reveal when and how to improve their Fault Navigation.
When you change a test, get it to fail, change the source, and get it to pass, each test run must be as easy as a few keystrokes—hopefully just one. That’s why you must spend a little extra effort to cobble together scripts and embedded command lines to put all these different test rigs, on both the server and client side, under one of your editor's buttons.
TODO Please read its entire Web site and source; it fits this , and insert all of that content here.
A pretty picture:
TODO My white arrow indicates the user’s mouse pointer forming a double-headed arrow over a splitter bar. All this behavior runs client-side, in a Web browser!
To illustrate Web testing, we will select a project with a slightly thinner client.
Unlike other Case Studies, this one cannot invite the reader to play along with the text, and make each change as presented. You have already learned the TFUI Principles for simpler projects; the project here must cover too much territory for each little refactor to provide readable prose.
Wiki Wiki Web sites present a range of test challenges. If you never heard of a Wiki, stop reading now and e-search the Internet for “WikiWikiWeb”. Ward Cunningham invented them, and co-wrote The Wiki Way: Collaboration and Sharing on the Internet, with Bo Leuf.
Some day there will be as many versions of Web sites with content that users can edit as there are Linux distributions. Their divergent features target various intents and whims. For example, my latest Wiki, called MiniRubyWiki (MRW), is written in Ruby, produces XHTML, and can display GraphViz output. (Try to survive those shocks!)
Wiki Wiki Webs
Humans, collaborating to write a Web site, most frequently want to upload simple paragraphs of text, containing a few markup codes and links to other pages in the same site.
The least simple solution gives all the users expensive “WYSIWYG” editors and complex upload protocols. The most simple solution gives each Web page an “EditPage” button. When you click it, you get a page containing the previous page’s content area rendered as a big edit field. The content area contains not HTML source but a tiny breezy markup language:
Analyzing users’ requirements, removing duplication from their behaviors, and trimming unneeded features all specify the simplest thing that could possibly work: A Wiki.
Here are the two most common Wiki typesetting markups, using ticks ', with their outputs seen through default browser settings:
this is ''em''phatic—this is emphatic
this is '''strong'''—this is strong
All Wikis provide a few more complex markups. But Wiki notation obeys constraints different from other authoring systems. HTML strictly reserves the tag marker <>—nothing else may resemble one. But Wiki markup obeys naïve users’ understanding, and advanced users’ expedience, over strict markup purity. A single tick ' is just an apostrophe. Wikis cannot indulge in arbitrarily complex markups. Many simply provide an “HTML Mode” for select pages, giving power-users free reign. And many reserve a special character at the start of a line, such as a bang !, to escape embedded commands.
Wikis express URLs, such as news:comp.software.extreme-programming, or http://www.dilbert.com/, as hypertext links to their targets. When such URLs begin with http: and end with a common graphics file extension, such as .gif, .jpg, or .png, Wikis instead display them using the command. To decorate a Wiki with graphic content, put graphic files on a web server, and enter their addresses into your page.
The absolute genius of the original www.c2.com Wiki, honored in all its followers, is its internal link protocol. A word with leading and embedded capital letters, such as WardCunningham, renders a link to the nearest Wiki page with that name. Users create a growing KnowledgeBase full of project details, written on pages named using ProjectSpecificJargon.
The reader indulges in the original meaning of “hyper” text—they can read a page from top to bottom, or they can read in the orthogonal dimension; out and back through other pages.
The core of every Wiki is a Representation Layer that converts Wiki markup into an HTML representation. MRW developed test-first. Its earliest features (with highest business value) transform one representation (the Wiki markup) into another (HTML).
These primordial assertions, for example, created and defended the Wiki markup:
got = formatWiki('FrontPage') # a ‘tag’, or internal link
got = formatWiki('baBaLoo') # not a tag
got = formatWiki('WinThirty2') # not a tag either
(assertEqLf() Fuzzily Matches HTML, disregarding many blank characters.)
Because MRW produces XHTML, one can test-last entire pages using validating parsers.
Validating HTML parsers make respectable tests. We prefer XHTML because XPath can incidentally validate as it queries contents. Many other fine validators are available. When they leverage awareness of HTML structure, they can detect errors in the meaning of the markup tags. For example, one should not put a
The program Tidy, by Dave Raggett, can read HTML and return a list of these issues. Get it at http://tidy.sourceforge.net/.
MiniRubyWiki used Tidy, early in its development, to constrain its HTML output. The case test_tidyDoesNotDespiseOurHTML() converts each page in a list from Wiki format into HTML, passes this through Tidy, and parses the extracted error messages. For any non-trivial error, the test case prints out the offending HTML line, with a caret ^ pointing at the beginning of the offending codes.
This system does wonders to constrain refactors so they strictly preserve behavior. The user, and their browser, might not care if a given stretch of HTML said:
Honestly, we still don’t care either. But if a refactor accidentally inverted those two end tags, it could invert other things, too. Tidy will stop us as soon as possible, and print out the line that failed. We will (usually) ignore the error message, tap Undo until it goes away, and try again.
Hyperactive tests are good because they prevent sloppy refactors. A hyperactive test fails when a user would not have perceived a bug. TFP produces many such tests, because over-constraining is cheaper than exactly constraining. When such a test fails, only the most recent edit could be at fault. If a module leverages such tests, ensure they run with its tests, not with the integration tests.
Pouring an entire page into a validator might be called a “bulk assertion”. Use such techniques aggressively, but watch out for two problems.
If we don’t ignore the error message, it does not directly indicate which line of source code caused the problem. The validator will reveal the line of XHTML that offended it, not the line of your source that caused the error. The error messages, and your test case’s diagnostic output statements around them, provide plenty of clues, but no smoking gun. Most of our tests approach the ability of a Unit Test to isolate our culprits.
Bulk assertions’ biggest problem is they can’t test-first. Validators that rely on HTML that already exists can’t enforce new features.
We will add to MRW some features more advanced than
|Dedicated to Ashley & Iris||Abramovitz, Janet N., and Ashley T. Mattoon. 1999|
|Plastics and the Environment. Hoboken. N. J. Wiley-Interscience. Ashley, S. 2002||Gilliland home is dedicated|
|Citations Acknowledging or using iris-related facilities and Data As of August 2010 Please send corrections and/or additions to||Dedicated to Jerry Lefcourt, Lawyer and Brother|
|Free to download magazine dedicated to Commodore computers||Morning session I: Dedicated to Prof. A. Acrivos, “Suspensions and particulates”|
|08: 30 Registration 09: 00 Welcome Remarks Morning session I: Dedicated to Prof. A. Acrivos, “Suspensions and particulates”||The Culture of Irises in the United States Iris Culture for the Mountain and Plains Region, D. M. Andrews 5|