Hacker News new | ask | show | jobs
by unit_testing 5375 days ago
What's the purpose of complex testing frameworks like this? What's wrong with using a simple framework whose tests must simply return a bool?

For example:

         var myObject = new Something("foo", "bar");	 
	
	 assert("simple operations", function() {
		return myObject.doSomething() == "baz";
	 });;
	 
	 assert("post-operational state", function() {
		return myObject.state() == 123;
	 });;
	 
	 assertAync("async polling", function() {
		return myObject.poll().length > 0;
	 });;
Note that those tests would be much prettier in CoffeeScript.

Is the purpose of heavy testing frameworks purely for the useful functions like "deepEquals"? If so, why not make a library with functions like "deepEquals" and use that library with a simple testing framework? Surely, there must be something I'm missing.

Edit: I should note that the beautifully written CoffeeScript compiler/translator doesn't use a testing framework (favoring a few simple hand-rolled functions), and it has a massive suite of tests.

1 comments

One advantage is debugging failures. If the test framework only knows that a test passed or failed, but not why, then you don't get to know why either, because it can't tell you.

For instance, many test runners will show you the expected and actual values when a comparison fails. If they're large blobs of text, it can show you a diff, etc.