22

assuming a yield of 3 per hour, that's 83000 hours. 8 hours a day makes 10,500 days, divide by thirty to get 342 mythical man months. I call them mythical because writing 125 tests per person per week is unreal.

can any wise soul out there on SO shed some light on what sort of mythical men write unreal quantities of tests for large software projects? thank you.

update chrisw thinks there are only 20k tests (check out his explanation below).
PS I'd really like to hear from folks who have worked on projects with large test bases

amwinter
  • 3,121
  • 2
  • 27
  • 25
  • 1
    Your analysis is incomplete. How many developers participated in writing tests? – Greg Hewgill May 29 '10 at 01:57
  • 19
    assume 9000. they finished the job in a single mythical day and then went out for a beer. – amwinter May 29 '10 at 01:58
  • 1
    Actually it's longer than that, there are not 30 work days in a month, figure an average of 20, meaning ~520 man-months. – Nick Craver May 29 '10 at 02:00
  • Where do you find the list/count of Webkit unit tests? – ChrisW May 29 '10 at 02:03
  • I'm with Chris - not that I have reason to doubt that number, but I'd be curious to see a reference. – Nick Craver May 29 '10 at 02:05
  • there are 243,491 files in the LayoutTests folder of the webkit source. This includes SVN metadata and doesn't account for the fact that a test might have a client and a server side. Also many tests have explanatory files. probably divide by 3 or 5 to get the real answer. – amwinter May 29 '10 at 02:12
  • The LayoutTests folder is at http://svn.webkit.org/repository/webkit/trunk/LayoutTests/ – ChrisW May 29 '10 at 02:28
  • @dvk real or mythical I hope it was free (free as in beer) – amwinter May 29 '10 at 02:53
  • In theory you write the test just before you implement the functionality, so it should be somewhere between 3 and 30 per hr. Thats the theory of course ... – James Westgate May 29 '10 at 13:16
  • May favourite unit test , passes every time: assert(result != value1 | result != value2) – James Westgate May 29 '10 at 13:19
  • 4
    @James These are system/regression tests, not unit tests. 1) Develop a `*.html` file which demonstrates the bug/feature 2) Write/debug the code which implements the feature 3) Use Webkit to render the test HTML 4) Capture the (good) result and say that this is the 'expected' result 5) Regression testing means rerunning the tests and verifying that the expected/good results are unchanged. They are *not* writing test-specific source code for each test. – ChrisW May 29 '10 at 13:24
  • IMO this question should be edited to remove the "unit-testing" label (perhaps replace it with a differet kind of "testing" label): because these seem to me to all be feature-specific system/regression tests, and not 'unit tests' at all. – ChrisW May 29 '10 at 14:01
  • @ChrisW - title says unit tests – James Westgate May 29 '10 at 15:07
  • @James the title says unit tests, but I think that the title is wrong ... the OP is talking about "the LayoutTests folder of the webkit source", and those don't seem to be unit tests. – ChrisW May 29 '10 at 15:15
  • chrisw is right. unit tests test functions or objects in isolation, they know about your program internals. these tests run on the whole program. i've changed the title. – amwinter May 31 '10 at 04:34
  • 1
    http://www.w3.org/2011/10/28-testing-minutes.html includes overviews of all browser vendors testing. (I can expand on the Opera stuff, if interested — we're now running ~360k tests per build.) – gsnedders Aug 13 '12 at 00:06
  • 125 tests per person week is not a high number. I probably consistently write that many *unit* tests per day when I'm just coding. *Update* For bigger (e.g. integration, system) tests though, no, I might slow down to 1 per week. :-) – Jonathan Hartley Jun 14 '16 at 17:39

9 Answers9

12

The original directory contained 240K files:

 Total Files Listed:
       243541 File(s)  1,062,470,729 bytes
       64718 Dir(s)

Many of these are svn files. If I remove all the subdirectories named ".svn" then the number of files drops to 90K:

 Total Files Listed:
       90615 File(s)    537,457,618 bytes
        7190 Dir(s) 

Some directories have a subdirectory named "resources" and/or "script-tests". I think that these subdirectories contain helper files which are used by test cases in the superdirectories. If I remove these subdirectories (because they don't add to the total number of tests) then the number of files drops to 87K :

 Total Files Listed:
       87672 File(s)    534,598,610 bytes
        6305 Dir(s)

Condensing 'similar' filenames (e.g. "arrow-keys-on-body.html" and "arrow-keys-on-body-expected.txt" are two files which define a single test) reduces the total number from 87K to 43K.

The only subdirectories which contain more than 1500 of these test cases (counted as described above) are:

2761   LayoutTests\dom
10330  LayoutTests\fast (of which 5934 are in LayoutTests\fast\js)
22575  LayoutTests\platform (with various O/S-specific subdirectories).

Within the platform subdirectories there seems to have been some copy-and-pasting between platforms. For example, the css3-modsel-37-expected.txt file exists:

  • In the LayoutTests\platform\mac\css3 subdirectory
  • In the LayoutTests\platform\chromium-win\css3 subdirectory
  • In the LayoutTests\platform\qt\css3 subdirectory.

If I discard filenames which are duplicated into several platform subdirectories, then there are only 5716 (instead of 22575) unique platform tests.

In summary I think there are about 18K unique tests: which is still an impressive number of tests, but fewer than the 250K that you had estimated in your OP.


By way of comparison, I recently found CSS2.1 Test Suite: that looks like about 9000 test cases for CSS.

ChrisW
  • 54,973
  • 13
  • 116
  • 224
7

I just wrote 4 unit tests in 5 minutes. Not all unit tests takes long to make. Some are very simple ;)

Thomas Winsnes
  • 1,961
  • 1
  • 13
  • 15
5
  • There are such things as automated unit test generators. For a complex function, you might often need to run all permutations of possible values of, say, 7 parameters. If they are boolean, you get 27=128 tests. For certain scenarios, these 128 tests are all generated using 10 lines of code.

  • Many regression-based unit tests can be generated by taking a large set of inputs, running the existing code on them, recording the corresponding outputs, and then making the gazillion tests which take new code, run it on same input and test that output matches old output.

  • Writing unit tests is a fairly distributed endeavor. Armies of interns/volunteers can do it in parallel.

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
DVK
  • 126,886
  • 32
  • 213
  • 327
  • 1
    that could be what's going on here but the ones I've looked at are pretty handcrafted. funky mathml, http header special cases. – amwinter May 29 '10 at 03:00
5

From the webkit contribution guidelines

"For any feature that affects the layout engine, a new regression test must be constructed. If you provide a patch that fixes a bug, that patch should also include the addition of a regression test that would fail without the patch and succeed with the patch. If no regression test is provided, the reviewer will ask you to revise the patch, so you can save time by constructing the test up front and making sure it's attached to the bug. If no layout test can be (or needs to be) constructed for the fix, you must explain why a new test isn't necessary to the reviewer."

Q) Who wrote those tests? A) Pretty much everyone who contributed to webkit.

Matt
  • 10,434
  • 1
  • 36
  • 45
  • I believe this but there must be more to it. who watches the watchers? somebody must have the nightmarish job of herding all these ducklings. – amwinter May 29 '10 at 03:47
  • I'm guessing there is some sort of code generation going on as well. Or maybe a single test uses an array of input data to run multiple times. – Mike Weller May 29 '10 at 12:53
3

These don't appear to be unit tests: they look more like system/regression tests.

This doesn't directly answer your question, but I've developed a browser of my own, so I might have have a little bit of insight into it; see:

can any wise soul out there on SO shed some light on what sort of mythical men write unreal quantities of tests for large software projects?

It's easy and necessary to write this kind of test:

  • Easy: write an html page (or similar black-box input), to exercise functionality/features/behaviour
  • Necessary:
    1. Need to test/exercise functionality when it's written
    2. Need to demonstrate/reproduce bugs when filing any bug report
    3. Need to keep all previous tests from 1. and 2., in order to do regression testing

A boss of mine once said, "You get what you inspect." (which implies that whatever you don't test is unknown/random).

Community
  • 1
  • 1
ChrisW
  • 54,973
  • 13
  • 116
  • 224
1

It really depends on how this was counted.

But anyways, once a good framework for testing a specific class/library/unit/whatever is set up, adding a new test is usually only a few lines. If they were writing tests with a goal of high code coverage percentages then those tests are typically even shorter because you do a lot of tests that vary only by the value of a single variable in order to get a different code path.

SoapBox
  • 20,457
  • 3
  • 51
  • 87
1

Your analisys is incomplete, at best. Or is biased, I guess.

You should count the number of testers, some (or all) of them fully dedicated to test and only test, what make them more productive. Also, you should realized that very few tests are complex in lots of projects and most of tests could be repetitive, so they could be easily implemented.

eKek0
  • 23,005
  • 25
  • 91
  • 119
  • right, you're asking the same question I am. how many testers were there. who are they. are they developers or QA staff? volunteers? – amwinter May 29 '10 at 03:02
0

In comments, you asked:

who watches the watchers? somebody must have the nightmarish job of herding all these ducklings

... and ...

right, you're asking the same question I am. how many testers were there. who are they. are they developers or QA staff? volunteers?

Perhaps your questions are answered at WebKit Committers and Reviewer Policy.

ChrisW
  • 54,973
  • 13
  • 116
  • 224
  • those are like robert's rules of order. it can't be that clean in real life. I want to hear stories from the trenches about the backroom politics. what is it really like to maintain a large testing base? what are the testing challenges mega-large software projects face. – amwinter May 29 '10 at 12:55
  • webkit is a project that went from the linux world (konqueror) to apple and is now shared with google. three very different cultures and styles, and this massive motherlode of tests. who are the heroes? who are the villains? the policy is good to know but I want the other side of it, too. – amwinter May 29 '10 at 13:01
0

assuming a yield of 3 per hour, that's 83000 hours

Given that there are only 18K unique tests, and 200 working days per person-year, then if you budget an entire day to develop each test, then a team of 9 full-time testers/people could develop 18K tests in 10 years (the KDE's KHTML and KJS projects began in 1998). These numbers are probably irrelevent (it may not take day to develop each new test case, and they may not have full-time/dedicated testers), but they do IMO illustrate that 18K tests over 10 years is feasible for a 'large' (or non-trivial), successful project.

I'm using a similar test strategy in my project: not because I copied Webkit, but because it's the only way I think of to do automated-but-maintainable regression tests of a GUI.

The following FYI is an example (one of the shortest/simplest examples) of one of my test cases. I generate it (and other like it) simply by manually exercising my browser's UI within a built-in test-case-generation framework. I can then run again later as an automated regression test (the framework replays the input and asserts that the output hasn't changed).

I find that creating the test cases is not what takes a relatively long time.

> clientSize 20 10
+ screenDisplays lines 0
----------
----------
> loadDocument lines 5
----------
<div>
<h1>Easy title</h1>
<p>Hello world. Lorem ipsum.</p>
<p>Embedded <a>anchor</a> tag.</p>
</div>
----------
< invalidateAll
> paint 0 0 20 10
+ screenDisplays lines 10
----------
····················
····················
··»«Easy title········
····················
····················
··Hello world. ·····
··Lorem ipsum.······
····················
····················
··Embedded anchor ··
----------
> mouse down 9 2
< ensureVisible 9 2 1 13
+ screenDisplays lines 10
----------
····················
····················
··Easy ti»«tle········
····················
····················
··Hello world. ·····
··Lorem ipsum.······
····················
····················
··Embedded anchor ··
----------
> mouse up 9 2
< ensureVisible 9 2 1 13
+ screenDisplays lines 10
----------
····················
····················
··Easy ti»«tle········
····················
····················
··Hello world. ·····
··Lorem ipsum.······
····················
····················
··Embedded anchor ··
----------
> keyDown Enter
< invalidate 2 2 16 1
< invalidateAll
< invalidate 2 4 16 3
< ensureVisible 2 5 1 16
+ currentDocument lines 6
----------
<div id="ModelText_id_contents">
 <h1>Easy ti</h1>
 <h1>tle</h1>
 <p>Hello world. Lorem ipsum.</p>
 <p>Embedded <a>anchor</a> tag.</p>
</div>
----------
+ debugDumpDom lines 15
----------
 1  div
 2    h1
 3      Easy ti
 4    h1
 5      tle
 6    p
 7      Hello world. Lorem ipsum.
 8    p
 9      Embedded 
10      a
11        anchor
12       tag.

Selected start={parentId=4,parent={tle},offset=0}, end={parentId=4,parent={tle},offset=0}

----------
> paint 0 0 20 10
+ screenDisplays lines 10
----------
····················
····················
··Easy ti···········
····················
····················
··»«tle···············
····················
····················
··Hello world. ·····
··Lorem ipsum.······
----------
ChrisW
  • 54,973
  • 13
  • 116
  • 224