user-pic

mascip

  • About: Perl, Javascript (AngularJS), Coffeescript, Firebase
Subscribe to feed Recent Actions from mascip

  • Toby Inkster commented on "Functional core & Imperative shell" : OO design, and isolated tests without mocks

    One class can happily pass a Point3D object to a second class. The second class can happily call the Point3D accessors and methods. However, the second class can't (easily) construct objects using the same Point3D definition from the first class.

    MooX::Struct can define methods. e.g.

    use Math::Trig qw(pi);
    use MooX::Struct Circle => [
       qw( radius colour ),
       area => sub {
          my $r = shift->radius;
          pi * ($r ** 2);
       },
    ];
    
  • Ovid commented on "Functional core & Imperative shell" : OO design, and isolated tests without mocks

    Other than an unreliable external service, why mock anything up? One argument I hear is "speed", but I'd rather have my tests correct than fast.

    Another argument I hear is "unit testing", but that's only because some people have an arbitrary definition of "unit" that somehow precludes fully exercising our code because we don't want it to talk to other code. I don't understand that.

    Yet another argument has been "this object is so hard to instantiate that we're just going to create a mock." I did that when I was a much younger programmer, not realizing that this is also known …

  • Ovid commented on "Functional core & Imperative shell" : OO design, and isolated tests without mocks

    Also, I should point out that while your title says "without mocks", aren't "test doubles" just the same thing? I guess I should watch that presentation now :)

  • Aristotle commented on "Functional core & Imperative shell" : OO design, and isolated tests without mocks
    Other than an unreliable external service, why mock anything up?

    Ovid, I linked you Gary Bernhardt’s Test Isolation Is About Avoiding Mocks in your own comments already – you really ought to read it. The (here deliberately over-summarised) punchline is that trying to test in isolation reveals invisible coupling. But really you ought to read the thing.

  • Samuel Kaufman commented on "Functional core & Imperative shell" : OO design, and isolated tests without mocks

    What external service is not unreliable? Any web service your code speaks to is by nature unreliable.
    Say for example your app sends emails. You write tests that send real emails. That's great, until the SMTP server goes offline. You've only tested against the live server when it was working, so you have no coverage for this.
    Of course, if it was your SMTP server you could turn it off and see how your code responds.
    If it isn't in your c…

Subscribe to feed Responses to Comments from mascip

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.