from Hacker News

Generating unit tests in Go

by jyz on 12/30/15, 9:04 PM with 23 comments

  • by andrewguenther on 12/30/15, 10:26 PM

    This is a really poor demo.

    I opened up the demo page and generated the tests. On first glance, I see a bunch of tests that just verify that the given code does exactly what it was written to do. That misses the _entire_ point of tests. Oh, and only a single test case for each function.

    Looking a bit more closely, the test cases wouldn't even pass. They're just filled with placeholder values. Okay, fine, the boilerplate is generated, but you have to fill in the expected returns.

    What about mocks? Why can I only have one test case per function? Also, None of these test cases are documented. You're really still writing the bulk of the tests yourself anyway.

    I'm not saying there is no value here, but if there is value, that demo shows none of it.

  • by Zikes on 12/30/15, 10:09 PM

    This would be great if it were implemented as a "go generate" compatible script or executable. [1]

    [1] https://blog.golang.org/generate

  • by twic on 12/31/15, 12:26 AM

    I assumed this was a joke about how bad some unit tests are. Then i thought it might be a satire on unit tests, from someone who really thinks they're pointless.

    Then i realised that this is a demo of a company that someone actually wants to make their fortune with:

    http://magictests.com/

    https://angel.co/magictests

  • by mholt on 12/30/15, 11:06 PM

    500 Internal Server Errors out the wazoo; e.g. http://magictests.com/static/js/bootstrap.min.js
  • by donatj on 12/30/15, 10:46 PM

    For some reason pasting code into it in chrome on Mac, it gets completely mussed up.