Unit Testing for C code
6 views (last 30 days)
Show older comments
Hi, I am actually using Simulink to test my C code, which is auto generated from Simulink model using Embedded Coder. This is very powerful of course, I have some doubts about the approach anyway.
My concern regard the Unit Test in particular, is the SIL test the more appropriate for this? It is certainly possible to perform unit test using SIL, but is that convenient? I mean, is it the best approach to produce a good Unit Test? The SIL testing should prove the adherence of the C code with the Simulink Model and this is more a Functional or black box type of testing, isn't it? I mean, this type of test is more focused on the entire System rather than on a single Unit. I know we can test our C code using Matlab script but since I don't have any kind of experience on its use, I'd like to know, is that better than SIL for unit testing? How about Matlab xUnit Test Framework, could it be used for C code? Does it have support for Stub and Mock? My point is, I want to bring more quality on my tests and I think this depends a lot on the tools, so any suggestion would be very precious. Can someone help?
0 Comments
Accepted Answer
Ajay
on 18 Aug 2017
Hi Vincenzo,
Would something like this help in the mean time then? - Simulink and the MATLAB Unit Testing Framework
It still employs SIL as the verification technology but you can do so for a specific component/subsystem/referenced model as opposed to the entire model /system.
Does that help to some extent? I am interested in hearing your thoughts on any gaps you encounter.
0 Comments
More Answers (2)
Ajay
on 9 Aug 2017
Hi Vincenzo
Do you think Simulink Test can help with what you are looking for? If you aren't familiar with it, be sure to check it out. From your description, it makes me particularly think about the Test Harness feature that enables you to create a test harness for specific components in a model (or the entire model but you are probably more interested in components anyway) and allows testing them in isolation. You could then use test harnesses in conjunction with creating and managing tests using Simulink Test Manager. Here's a relevant example .
Also, starting R2016b release, the MATLAB Unit Testing framework recognizes tests created using Simulink Test Manager (*.mldatx) so you can run them together with your other MATLAB based tests homogeneously using the MATLAB Unit Test Runner.
Does that help?
-Ajay
0 Comments
See Also
Categories
Find more on Test Model Components in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!