News for hackers. Stuff that matters.
Re:Testing code is simple by EGreg on Thursday September 26, 2013 @02:15PM (#6452563)
how are they worse?

I don't want.to.sitThere.writingThis(kindOf, crap)

Re:Testing code is simple by dragonwriter on Thursday September 26, 2013 @02:25PM (#6452639)
> how are they worse?

The code reads worse for a number of reasons:

:: you've written an equality, rather than truth, assertion named "assert" rather than "assertEquals".

:: you're writing what would be the code of a truth assertion as a string for the message test.

For the same role, most unit testing frameworks have an equality assertion / expectation assertion that serves essentially the same role but reads better.

> I don't want.to.sitThere.writingThis(kindOf, crap)

Then don't use spec-style frameworks. There's plenty of xUnit and similar style frameworks that use simple assertions (and, yeah, you can just use bare truth assertions all the time if you want, but you've usually got a handful of nice tools for common cases like equality assertions to go with them.)

Re:Testing code is simple by EGreg on Thursday September 26, 2013 @03:23PM (#6453008)
Fine, how about this:

  function testCase() {
     // do some stuff
     assert(a>=b, 'less pictures than participants', a,  b);
     // do some stuff
     assert(cool.length, 'cool is empty');
  }
output:

  "testCase: less pictures than participants (3, 4)"
  "testCase: cool is empty"
easy, no?
Re:Testing code is simple by dragonwriter on Thursday September 26, 2013 @06:41PM (#6454080)
If you want to write your own one-function test microframework on that model, feel free; I don't see any reason to prefer using it to existing frameworks, whether xUnit-style or spec-style.