Getting test religion

nkuitse on 2003-02-12T18:10:37

Test::Inline is wonderful.

Test::More is terrific.

It's only in the past month or so that I've begun writing lots of small tests. It's only in the past month or so that I've begun writing any test code to speak of. My eyes are wide open now to new vistas.

I'm a very happy camper.

I'm tickled pink.

I'm pleased as Punch.

But in the last few days, I've found myself coding so fast that I haven't paused to write tests. Well, maybe two or three short ones. And a longer one. I guess that's not so bad: a few is better than none at all...

I wonder: am I coding fast because my newfound test religion makes working code easier to produce? No, I don't think so.

But suppose I hit that familiar wall and the code engine dries up. What then? Well, I go back to writing tests; that may just be my ticket back to Happy Hack Mode Land.


Super Happy Test Speed

chromatic on 2003-02-12T19:27:13

If you want a real rush, get into test-driven development. Write a test, watch it fail, then write the code to make it pass. It's a weird but enjoyable experience to realize "That's all the code I needed to write!"

Re:Super Happy Test Speed

nkuitse on 2003-02-12T21:03:29

Actually, that's what I'm aiming for. That, or something very like it. I just need to set things up so I can cycle from design to test to code to design to test to code more easily (i.e., all from within my editor and my browser rather than switching and shifting gears ad nauseam).

The individual tests in the modules I've been working on tend to be pretty long, though. Maybe Test::Inline can be convinced to help with that (e.g., let me specify a 'preamble' of setup code that all tests can use). Sometimes cranking up a new .t file is a breath of fresh air.

I've looked at Mock::Object a couple of times now and the idea of it is very appealing, but I need to mull it over before I grok it. Much mulling may be required.

My current project will depend on a custom object model, which is what I'm developing now. Once I'd gotten a whiff of design-and-test-and-code-all-at-once, it didn't take me long to realize I could use the idea of worlds of objects to set up different test environments: I can create simple worlds for simple tests now and grow into bigger worlds over time.