Is the class-, function-, or script-based testing best for Unit Testing?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 2 de Jul. de 2021
Respondida: MathWorks Support Team
el 2 de Jul. de 2021
I want to unit-test my code but MATLAB has multiple approaches based on classes, scripts and functions. Which is the best?
Respuesta aceptada
MathWorks Support Team
el 2 de Jul. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Write Unit Tests en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!