10-22-2018 11:05 PM
Hello all,
I am planning to use the Unit Test Framework (UTF) in my project to test some VIs. All the VIs include objects to be passed through them. Also, I want to integrate the tests with Jenkins. I wanted to know the best practices to be followed while writing a unit test (mainly for object-oriented LabVIEW VIs) and which testing framework can I choose for testing the VIs (As there are a couple of objects to be passed through the VIs, I am not sure which one would be best to test them). Please give me your thoughts on this.
Thanks in advance.
10-23-2018 12:14 AM
Hi Bhargavi,
If you are using objects I would probably recommend avoiding NI UTF. To use objects with it requires writing custom tests for everything which can be a little cumbersome.
Of the other options I like VI Tester - it is all LabVIEW code so works well with objects and I have it integrated with Jenkins so that is possible. Not sure about Jenkins integration on others but I'm sure someone can let you know.
As far as best practices, the easiest thing I can do is point you to some of my blog posts 🙂 https://devs.wiresmithtech.com/blog/tag/unit-testing/
Cheers,
James
10-23-2018 02:14 AM - edited 10-23-2018 02:24 AM
Hi Bhargavi,
another option is InstaCoverage: http://sine.ni.com/nips/cds/view/p/lang/hu/nid/216652
InstaCoverage is a new unit testing tool for LabVIEW code. It comes with a free trial.
Here is a Jenkins demonstrator which integrates InstaCoverage for an example LabVIEW project: https://build.incquerylabs.com/jenkins/job/instacoverage-ci-demonstrator/job/master/
A documentation of the example can be found here: https://github.com/IncQueryLabs/instacoverage-ci-demonstrator/wiki
Although the example code in the demonstrator is not object-oriented LabVIEW, InstaCoverage works for LVOOP too. The demo project of the tool (included in the installation package) is an object-oriented example. Above Jenkins example would look like pretty much the same with object-oriented code too.
In general UTF and InstaCoverage come handy if you want to measure code coverage. Also, they support explicit test configuration files (.lvtest and .instacov), which come handy when structuring your test projects. In other cases, VI tester can be a good choice too.
Peter
10-23-2018 02:14 AM
Hello James,
Thanks for responding and pointing me to your blog posts, I will surely look into them
Can you elaborate on the point "To use objects with it requires writing custom tests for everything which can be a little cumbersome"? It would be great if you could give an example and demonstrate why do we need to avoid NI UTF when using objects.
Thanks again
10-23-2018 03:19 AM
Hi Peter,
Thanks for letting me know about the new unit testing tool(InstaCoverage):smileyhappy:
I also wanted to get clarified on a few things
1) Do you see any advantages in InstaCoverage against VI Tester? Which one would you prefer to use?
2) Why is NI Tester not a good choice? (Any reason for not even mentioning about NI Tester)
3) Please mention if you have faced any difficulties in using the VI Tester.
Thanks in advance
10-23-2018 07:42 AM
Hi Bhargavi,
Sure. The NI UTF is designed to work on a connector pane, so you chose a VI and chose what to put in the connector pane.
This doesn't work with objects since they normally need some code to set them up since you can't enter the internal values on the connector pane.
So instead you have to create a new VI with a cluster that you populated with pass/fail details. This works perfectly well but I found that this way of writing tests was easier in VI Tester than UTF.
Cheers,
James
10-23-2018 08:21 AM
Hi Bhargavi,
I attach a table comparing different tools for unit testing LabVIEW code. It's an excerpt of a talk I will give tomorrow at NI VIP in Fürstenfeldbruck, Germany.
Which tool is the best for you depends on your needs. Object-oriented code can be handled by all of them (with varying overhead as James also pointed out).
I don't know NI Tester, what is it?
Peter
10-23-2018 10:18 AM
Hi Bhargavi,
Check out the pinned post on this forum at https://forums.ni.com/t5/Unit-Testing-Group/TS3370-Save-Time-and-Money-With-Unit-Testing/gpm-p/35287...
It is from a presentation I gave at NI Week 2014. Scroll down to the end, there is a video showing how to do custom tests for Unit Test Framework. Before that, there are different demonstrations using JKI VI Tester and Unit Test Framework.
I need to go back and add the same demonstrations using Peter Bokor's InstaCoverage tool. Peter and his team at IncQueryLabs are doing a great job addressing all of the community concerns. Among them the fact that, as James noted, it is hard to test LVOOP code with UTF.
Regards,
Fab
10-23-2018 09:59 PM
Hi Peter,
Thanks for attaching the comparison table, looks like VI Tester suits my needs
I was mentioning NI UTF as NI tester, Sorry if I used it wrong.
10-23-2018 10:38 PM
Hello Fab,
Thanks for the videos, they are really useful
I will be waiting for more videos of yours to get the best out of testing frameworks