On Mar 5, 2020, at 9:26 AM, Warren Stephens <wsteph...@prognoshealth.com> wrote: > > And I am saying Functions PLUS Structure. > > > > Functions remain. Visible structure is added.
Right, and you can do your testing at the boundaries of those functions, because the structure is nothing but a shell (in most Step Lambda cases, just a state machine) that runs the lambdas. That's what's also suggested for how one should structure Go code for testability; if you want to test something, it should be externally visible as part of the established, documented interfaces. If you're trying to externally test function internals, you are inevitably setting yourself up for a lot more maintenance headaches down the road because the internals of a function are not (or should not be) subject to control by the specification. Consider the testing approach defined by Cucumber (whose excellent Go implementation is available as "godog"). You can actually write the entire specification as a series of tests, if you wanted to. But the point is that it tests as a set of externally-observable behaviors, not relying on "this magic internal value should be set to this value". It will save you a LOT of time in the end, even if it requires significant mental effort and dragging people along with you. I spent the last year and a half trying to push changes like that at my org, and it was beginning to show tangible benefits right before the project got shut down for other reasons. Making your tests organized, consistent, readable and repeatable will make your life so much easier in the end, even if it seems insurmountable right now. And if your org is resistant to spending the time necessary to clear away the technical debt that's been built up by (probably decades of) lax engineering approaches? It's probably a sign that either you need to put your foot down more and/or sell it by noting that reduced defects means increased velocity and less embarrassing fires to put out, or you should start polishing your resume, because there are many orgs out there that will probably pay you more to do it right. - Dave -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/32F8B9ED-5A90-476E-9D6D-76F3A4D704CE%40gmail.com.