Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I put my testing code in relation to the code it is testing?

The two obvious places I can think of would be some sort of "testing" folder right next to the code I'm working on. So something like:

\project-code
    \my-feature
        \production-code
        \testing
            ***my tests***
    \co-workers-feature
        \production-code
        \testing

Or I could split out the testing code a completely separate hierarchy. So something like:

\project-code
    \my-feature
    \co-workers-feature
\testing-project-code
    \my-feature
        ***my tests***
    \co-workers-feature

I've seen a lot of frameworks use the second approach, but recently we've been putting our testing code within the production code mostly for convenience. Is one approach much better than the other or is there a best practice here?

like image 905
Bialecki Avatar asked Dec 10 '25 12:12

Bialecki


1 Answers

Put them where it is most convenient for you. You can set up your build system to remove them from the final product, if desired. Testing is a "best practice". Anything that makes testing easier without reducing its effectiveness is simply improving on a best practice.

like image 65
Christopher Bottoms Avatar answered Dec 14 '25 01:12

Christopher Bottoms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!