In AlphaSimple, you can create models whose only purpose is testing other models.
A test suite is a class with operations marked with the “Test” stereotype:
1 2 | [Test] operation testBasic(); |
In order to apply a stereotype it must be defined in a profile, and that profile must be applied to the test package. But you don’t have to write a test profile, you can use this one. To use it, load the profile and apply it to your test model:
1 2 3 4 5 6 7 8 9 10 | model mytests; load <<http://alphasimple.com:8090/mdd/publisher/rafael-703/test_profile.uml>>; apply test_profile; class MyTestClass [Test] operation test1(); ... |
If you roll your own test profile, just make sure the stereotype is named “Test”. You will also need to write your own assertion utilities (which you get for free from test_profile).
Finally, enable tests by ensuring your project has a mdd.properties file with this:
1 | mdd.enableTests=true |
That is it – now, when saving a model, if compilation succeeds, your test cases will be automatically executed, and if they fail (raise exceptions or break constraints), resulting failures will be reported as build errors below the editor.
