Un responsabile tecnico del mio team ha detto:
We're going to use sonar on our (500KLoc) codebase so that everytime you do a commit, it will check the classes you've touched against the coverage goals. If you don't meet the coverage goals for your commit, the build will break.
Un altro sviluppatore ha risposto:
No that has no value. The classes were written against a specification with particular test scenarios in mind. It's not possible to discover what those test scenarios were from the code. You can't write a useful JUnit test on legacy code because you don't understand the original intent.
Il primo lead tecnologico ha risposto:
You can infer the requirements from the codebase, and the user experience of the software. All the JUnit test does, even if it does capture the original test scenarios, is demonstrate that a working path exists in the code. You can't say that JUnit tests represent a proof, but providing coverage of the code is extremely valuable.
La mia domanda è: Quando scrivi un test JUnit per codice legacy non coperto: quanto è importante capire gli scenari originali?
Modifica : Si noti che questo è diverso dalla domanda collegata perché riguarda i intento o i requisiti inferti come input per i test JUnit sul codice legacy.