Is the class-, function-, or script-based testing best for Unit Testing?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 2 Lug 2021
Risposto: MathWorks Support Team
il 2 Lug 2021
I want to unit-test my code but MATLAB has multiple approaches based on classes, scripts and functions. Which is the best?
Risposta accettata
MathWorks Support Team
il 2 Lug 2021
Class-, function-, and script-based testing are all equally valid approaches. All three are also valid xUnit implementations. Which one is used is determined by the features one wants to use and what style he prefers and is comfortable with writing.
Class-based tests provide the most features (e.g., code sharing via inheritance, shared test fixtures, parameterized testing) while script-based tests offer fewer features. On the other hand, script-based tests are much easier to write, especially if one is not comfortable with object-oriented programming. Function-based tests are somewhere between class- and script-based tests on the ease-of-use vs. capability spectrum.
If you are interested in taking advantage of the most powerful features in the testing framework (and not averse to writing classes), it would be suggested to write class-based tests.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Write Unit Tests in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!