Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: What to test in a new module

by hippo (Bishop)
on Mar 11, 2023 at 10:54 UTC ( [id://11150921]=note: print w/replies, xml ) Need Help??


in reply to Re^3: What to test in a new module
in thread What to test in a new module

Unless you're designing and writing code against a predefined spec/RFC, I really don't feel like strict adherence to TDD is beneficial.

To me, that's partly the point. If you can't write the tests because the spec is wrong/contradictory/woolly/absent then that's a problem with the spec. Test Driven Development requires a solid spec, otherwise it's a non-starter.


🦛

Replies are listed 'Best First'.
Re^5: What to test in a new module
by stonecolddevin (Parson) on Mar 11, 2023 at 19:25 UTC

    I agree up to the point that you're building to spec because someone said you need a certain endpoint just because they thought it feels good. I don't think everything gets done in design meetings and I think there needs to be some relatively well thought out code written before you say "ok here's our API spec".

    Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

      I think there is a chicken-and-egg problem in this discussion and you all are talking about different layers of tests.

      When designing an API is beneficial to write demo usage code. Like the synopsis part in a CPAN module. These can be tested against proof of concepts. That's the nucleus of the project.

      When adjusting the spec you need to adjust those demos, hence code and test suite grow in the process.

      After those are sufficiently stable you start wiring the POCs into modules with more specific unit tests, for instanceto cover edge cases.

      But the tests you wrote while designing the API are already there.

      You may have decided to change the internal architecture in the middle and split the code into multiple dependend modules behind the API. Different modules will have different unit test suites.

      For me it's an iterative process, but this first layer of API tests will stay quite stable while the POCs will only be kept for historical reasons.

      These API tests are the first tiny eggs if you want...

      Cheers Rolf
      (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
      Wikisyntax for the Monastery

        I guess I'm just not really a fan of throwaway tests. It sounds like like you're either assuming the demos are stable or are writing throwaway tests and don't mind the churn.

        Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11150921]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found