I'm almost done a PhD in mechanical engineering. Some CS folks have lamented gaps in my programming-related education, but I actually did take an elective course on the reliability of science which included a lot on scientific software testing. I think such a class should be required for anyone working in theory or simulations.
In engineering, concerns about the testing and accuracy of a model are typically called "verification and validation". There unfortunately doesn't seem to be a standard curriculum for the subject yet but Wikipedia can give you an idea of what this covers and how it's different from general software testing: https://en.wikipedia.org/wiki/Verification_and_validation_of...
AI/ML seems to have their own culture around this and I'm not sure its actually rigorous. Seems to me that they could have their own version of the reproducibility crisis.
This course should be taken after a statistics course. Parts of it rely fairly heavily on statistics.