Yet another (LabVIEW) blog

Modifying VI Tester template

[Originally posted on 2018-08]

VI Tester from JKI – is great tool for unit testing in LabVIEW. I’ve already described it in my blog post http://kosist.org/2017/06/jki-vi-tester-useful-tool-for-labview-developer/.

This time, I’d like to tell couple words about how to modify default VI Tester Test Case template class, so each time when you create new Test Case, you will use your own template.

Everything is very easy. First, let’s assume that we’d like to modify default template in a way, that we will have there Given, When, Then template for unit test. Given, When, Then In LabVIEW Tests concept is described in details in this great blog post https://devs.wiresmithtech.com/blog/given-when-then/ from James McNally, Wiresmith Technology technical blog.

I also found it quite useful, and it really helps to structure different test case scenarios into one layout – so it is easy to understand and modify unit tests.

We could create this template by ourselves, or we could go to https://github.com/WiresmithTech/VITAC, open-source project from James McNally for Advanced Comparisons for VI Tester library. This library has more methods for VI Tester comparisons, plus couple more templates for unit tests themselves.

So, let’s download the latest release from here –  https://github.com/WiresmithTech/VITAC/releases, install it to LabVIEW, and VITAC pallete will appear in Addons pallete.

Now, let’s modify VI Tester TestCase template class. It is located in the following directory (in my case, I use LabVIEW 2017): C:\Program Files (x86)\National Instruments\LabVIEW 2017\resource\JKI\VI Tester\Templates\TestCase.

Note, that for each LabVIEW version you need to modify test case templates separately.

Let’s open it:

First of all – I don’s use those “private” and “protected” virtual folder, so let’s remove them. Instead, let’s add two other virtual folders – “tests” and “templates”, and move testExample.vit template VI into “templates” folder.

Let’s open it, now it looks like this:

We may remove code in Enabled page, and after go to functional pallete -> Addons -> VITAC -> Templates -> Given When Then.vi.

And place it into the code, and connect wires. VI remains broken, because inputs of passIfEqual.vi are not connected. Let’s add there string constants, as the following:

That’s it. Last point – let’s delete example VI under test, temp_VI_UnderTest.vi; and save our TestCase.lvclass. It will look like this:

From now on, while creating new test case via LabVIEW menu Tools -> VI Tester -> New -> Test Case…, VI Tester will use this template for new Test Cases. You may modify as you want, add more templates for different scenarios, virtual folders, etc. – so, customize it to fit your needs!

Of course, it would be much nicer to have option to use more Test Case classes templates, but this is still just the suggestion at github, for VI Tester project – https://github.com/JKISoftware/JKI-VI-Tester/issues/2 (actually, the oldest issue in the list =)). Hope, that in near future JKI or someone else could implement it to VI Tester, and make it even more easier and pleasant to use.

Thank you for your time, and looking forward for any feedback!

Leave a comment

Your email address will not be published. Required fields are marked *