05-02-2018 08:41 AM - edited 05-02-2018 08:44 AM
Hi,
are there any best practices, doing automated software-tests by using simulated devices.
For example, there's a VI which uses a scanner, force measurement, temperature measurement, &c.
And I want to use VI Tester or a similar tool to run tests that put different sample-values into some kind of simulated device to check, if the whole VI-system is working alright.
Is there anybody who has some experience in doing something like that or any ideas, who to implement it?
Greetings
Elias
05-02-2018 08:57 AM
Elias,
Have you looked at the "Unit Test Framework?" This is a framework that ships with most LabVIEW editions. Unfortunately, it does not install by default! (Hmmmm maybe an Idea Exchange Idea.... Then again....)
Reinsert your media and install the UTF. Examples will also install. Use the example finder to find the projects to review.
BONUS: I presented on that to the Minneapolis LabVIEW Users Group some time ago. The pptx. exists somewhere around here (Sorry, NI has "Enhanced My experience" and now the pptx is hard for me to find)
UTF is not the end-all-be-all of automated testing for software components but, Its a nice place to start
05-02-2018 08:58 AM
Hi Elias,
you need to implement such "simulated signals" into your device drivers!
Example: with DAQmx you can simulate the DAQmx devices and you will also get simulated signals when using such a simulated device.
For external devices (like your "scanner" maybe) you need to implement such things on your own, after checking the presence of those devices…
05-02-2018 02:35 PM - edited 05-02-2018 02:36 PM
One thing I would second onto GerdW's reply is that, while you can create a "simulated device" in NI MAX, the simulation cannot be fully controlled which is typically what you need when doing unit testing. Simulated devices in MAX are useful to check code that uses said devices for general functionality (aka "developer debugging tests") but are not deterministic which is a fundamental requirement for good long-term unit tests run in the test framework of your choice (be it NI UTF, JKI VI Tester / Caraya etc.)
05-02-2018 05:43 PM
Where I work, we made the decision to make all instrument references into LVOOP classes, all of which have a common ancestor with a limited set of required functions (Initialize, Stop, etc.). Our own custom HAL (hardware abstraction layer) implementation. You can find other posts and probably some white papers about other people's implementations.
The part that's relevant to what you're looking for is that once you've created a LVOOP class for your scanner, and made all the VIs in it that communicate with hardware into Dynamic Dispatch, it becomes super simple to create a descendant class that overrides all of the VIs that do hardware communication and replace them with VIs that don't communicate. You can have these descendant classes return hard-coded values, read values from a file to return, or have them interact with other simulated instruments in the background to produce reasonable test values (for example, if you simulate a power supply and a multimeter, you can make it so the value your multimeter reads is dependent on the set point of your power supply, even though neither of them really exist.
Once you've done all that, all you have to do is load in an instance of the simulated LVOOP class instead of the standard one, and then as long as you're passing your references around properly your entire codebase can be tested with simulated instruments with one toggle.
05-03-2018 01:30 AM
Yes I already had a look at it. I also tried Caraya, but as a LV-newbie UTF impressed a little bit more to me.
Which are the pro's and con's of that different testing-tools?
@Kyle97330: We already are using such classes. But we would like to test the whole system in a as wide range as possible.
05-04-2018 06:13 AM
Is NI VeriStand some kind of tool, which would work for my plan of doing automated testing?