Unit Testing Modelica Component Library?

I am creating a component library in Modelica and would be grateful for the input of the unit test methods for the package.

So far I have a test suite consisting of a set of models, one per component. Each test model creates an instance of the component and connects it to some very simple helper classes that provide the necessary inputs and outputs.

This works great when used interactively in OMEditor, but I'm looking for a more automatic solution with pass / fail criteria, etc.

Should I start writing .mos scripts or is there another / better way?

Thanks.

+6
source share
4 answers

I like how the Openmodelica test results look, see

Although I have no idea how they do it. Obviously, some kind of regression testing is being carried out with preservation of the previous results, but I don’t know if it was obtained from some testing library or made independently.


In general, I find it rather sad / suboptimal that there is no β€œone-stop” testing solution that everyone can / should use everything (see, for example, the nose or pytest in the python ecosystem), instead everyone seems to be preparing their own solutions (or trying), and all you find is some Modelica conference documents (often without a trace of implementation) or an unattended library with unknown status.

At the top of my head I found / know (some are already linked in other answers here)

This is similar to a pathological instance https://xkcd.com/927/ . It is impossible for a user (not dev) to know which one to choose, which is actually good / usable / available / ...

(Not real testing, but also relevant: analysis and semantic analysis using ANTLR: modelica.org/events/Conference2003/papers/h31_parser_Tiller.β€Œ pdf)

+6
source

Writing a .mos script would be one way, but Michael Tiller also has a small library of evidence-based concepts: XogenyTest , which you could use as a base.

+3
source

If you have Mathematica and SystemModeler, you can run the simulation from Mathematica and use the VerificationTest "function" to verify: VerificationTest[Abs[WSMSimulate["HelloWorld"]["x",.1] -.90] <.01] .

Several tests can be modeled in TestReport[] .

+3
source

I prefer using the .mos script, it works great when you integrate your test environment even more into the continuous integration tool. BuildingPy is a good example of this, although it is not implemented in CI tools, it is still a good tool.

Here's a link to a good framework design: UnitTesting: a library for testing Modelica modules

+2
source

Source: https://habr.com/ru/post/1245562/


All Articles