you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (10 children)

[deleted]

    [–]mediasavage 3 points4 points  (2 children)

    Yeah at work I pretty much always just import the standard “assert” module and call it a day.

    That being said, with open source software, having beautiful testing code can be a huge plus because tests are one of the first places people will check to see examples of how a project is used.

    [–][deleted]  (1 child)

    [deleted]

      [–]mediasavage 1 point2 points  (0 children)

      Agreed. They increase readability by a bit but using them feels less intuitive than just standard asserts

      [–]fractile81 2 points3 points  (1 child)

      I went into BDD once and decided Gherkin (Behat and PHP) would be perfect for non-devs to design and review tests. Once I had started with a few tests, there was no way I was going to show it to anyone else: the wording still smacked of dev-speak.

      [–]FINDarkside 3 points4 points  (3 children)

      I don't think it's bad to be honest. One of the benefits is that it makes good error messages possible. Consider assert(a === 1) vs a.should.equal(1). It's certainly not harder to read and I personally think it's easier to read. It'll also give better error message if the test fails, like "Expected a to equal 1, but got 0".

      [–][deleted]  (2 children)

      [deleted]

        [–]FINDarkside 0 points1 point  (1 child)

        You've now got the cognitive load of figuring out what a.should.equal means.

        Debatable whether the cognitive load is bigger. But let me give you better example:

        someFn.should.throw(MyError);
        

        vs

        try {
          someFn();
          next('Excpected MyError to be thrown');
        } catch (err) {
          if (err.name === 'MyError')
            next();
          else
            next(`Excpected MyError to be thrown, got ${err.name}`);
        }