Unit Testing for C code

조회 수: 2 (최근 30일)
Vincenzo Fiarè
Vincenzo Fiarè 2017년 8월 9일
답변: Ajay 2017년 8월 18일
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?

채택된 답변

Ajay
Ajay 2017년 8월 18일
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.

추가 답변 (2개)

Ajay
Ajay 2017년 8월 9일
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

Vincenzo Fiarè
Vincenzo Fiarè 2017년 8월 10일
Hi Ajax
and thanks a lot for your answer.
I've heard something about Simulink Test before and in fact I thought it was great. The think is, my license does not comprehend this tool; it could be available to me in the future, but until then I need something else.
Any idea?

카테고리

Help CenterFile Exchange에서 Test Model Components에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by