Thank you for correcting me regarding framework vs. library. Please see my responses inline.
What is your response to this?
> > I believe that some of the features of this unit testing framework
> > actually make it quite hard to read by someone else. For example,
> > below you mention that tests can be commented out by placing an
> > exclamation point at the beginning of the test description. This
> > seems like a very obscure and non-obvious trick that won't be
> > caught by many people without extensive documentation reading.
>
> I'm afraid you misunderstood me: this is not a unit testing
> framework, but a library that will enable us to write unit tests in
> a uniform format in *together* with the existing test frameworks:
> Mochitest and XPCShell. Please note that I'm using NodeJS style
> assertions here as an example. Perhaps I picked that one poorly, but
> I hope that you can fill in the gap.
>
> The most important thing about commenting out a unit test with a "!"
> is to allow more flexibility during a TDD workflow. This whole thing
> is meant as a tool for developers, not TBPL maintainers. Another
> example is the Growl notifications; they would not work and not make
> any sense on our build servers, it's just there to make your life a
> tad easier when doing TDD.
>
> The "<" in the test name is meant to signal out a test case and run
> only that specific one. This is something that is practically useful
> when doing TDD.
Many test frameworks will stop the test after failing the first assertion. Mochitest doesn't, so disabling a test while authoring isn't so much of a necessity. Regardless, we also have todo() which you could use while writing the test if you so please.
I think this conversation is too hard to discuss in the abstract. The sample code provided doesn't relate close enough to how we actually write tests.
This may be better discussed if we use a test from mozilla-central as an example. The following test could have been written before the code-under-test was written, aka TDD:
How would this testing library make this test easier to read? What issues do you see with this test?
Thanks,
Jared
I see I have done a poor job at showing a good & proper example, so please take a look at this:
- https://github.com/mikedeboer/mozAsync/blob/master/examples/browser_aboutHome.orig.js
- https://github.com/mikedeboer/mozAsync/blob/master/examples/browser_aboutHome.js
This is the browser_aboutHome.js unit test code vs. a rewritten version with AsyncTest.
The NLOC difference is minimal (~100 lines), but the more significant improvement here is the structure that is proposed as uniform.