Il rapporto tra requisiti, casi d’uso e test è centrale per lo sviluppo software.
L’individuazione e la descrizione dei casi d’uso sono attività molto efficaci per agevolare la scoperta dei requisiti, e per favorire una validazione degli scenari di utilizzo da parte degli stakeholder. Ma i casi d’uso, in sé, non sono requisiti, e certamente non sono sufficienti per scoprire tutti i requisiti.
D’altro lato, la definizione precoce dei test di accettazione è eccellente per eliminare le ambiguità dai requisiti, perché costringe a precisarli. Ma i test non possono essere sostituiti ai requisiti.
Il rapporto tra requisiti, casi d’uso e test (oggetto dei miei corsi “Gestione dei requisiti con i casi d’uso” e “Test di sistema e di accettazione”) è descritto in dettaglio da Bertrand Meyer. Vale la pena leggere tutto il suo intervento, di cui riporto il passo centrale:
“The insight, which has significantly improved the practice of software development, is that the regression test suite is a key asset of a project and that tests should be run throughout. The bad advice is to ditch upfront requirements and specifications in favor of tests. The property that tests lack and specifications possess is generality. A test is an instance; a thousand tests can never be more than a thousand instances. […] the relationship is not symmetric: one can generate tests from a specification, but not the other way around.
The same relationship holds between use cases and requirements. It is stunning to see how many people think that use cases (scenarios) are a form of requirements. As requirements they are as useless as one or ten values are to defining a function. Use cases are a way to complement the requirements by describing the system’s behavior in selected important cases. A kind of reality check, to ensure that whatever abstract aims have been defined for the system it still covers the cases known to be of immediate interest. But to rely on use cases as requirements means that you will get a system that will satisfy the use cases — and possibly little else.”