08-12-2014 02:28 PM
So I have been trying to really get the habit of unit testing going.
The easiest way I have found so far is simple. Whenever I go for the run button on a subVI because I have filled it in to test it, instead create a unit test with UTF. Once I have run it and happy there is a single button to import the values and now my test is recorded for all time to be re-run as needed. It needs to ultimately progress further but I have found it a good way to build the habit.
What is interesting is for once LabVIEW could be on the forefront of unit testing! It reminded me of a podcast I recently listened to about an idea called approval tests. Each time the test fails the user can import the new results as correct on inspection, it's not quite the same but actually closer to what I described earlier than normal unit testing! The podcast is http://www.thisagilelife.com/46/ if your interested.
I'm curious, how did other people start getting it into their workflow?
Cheers,
James
08-12-2014 02:57 PM
A good next step is to automate your unit test run on a continuous integration server.
What we do in our labs is we have a Jenkins Server that is polling our source code control server. We have a job set up to run all unit tests on a project at check in.
The nice thing about this is that instead of relying on making running the unit tests a habit, you can just automate that part away. Also this frees up your machine to work on other tasks while your tests run on the server (not to mention in any team, there's always at least one person who forgets to manually run the tests...).
There are a few items in setting up Jenkins and LabVIEW that aren't totally obvious but if you have questions feel free to ask.
Scott
08-12-2014 03:15 PM
We have a build server we run as well (TeamCity). Much like Jenkins the build is triggered by source control check-in. We have a generic module we call GBuild that is called to build the specified project, update the build version to the build server definition, run any unit tests and execute any present VI Analyzer configuration. Messages are passed back to TeamCity so that the entire build log is captured and browsed (eg. the history of unit test results), just like any other build type such as .NET.
Because of the lengthy time to actually do all this we don't always trigger a build on every check-in. We prefer regular check-in but scheduled builds for LabVIEW projects.
We don't use UTF much at this stage - we found the lack of object-oriented support / mocking frustrating since we always had to write a bunch of custom tests for everything which also mitigated code coverage. We use VI Tester now that it supports LabVIEW 2012 onwards. Prior we had to use our own framework GUnit which was structured virtually the same. Maybe we'll come back to UTF some day and automate some of the frustration out.
08-12-2014 03:20 PM
What are the limitations with UTF with respect to classes that you are running into tyk007?
We have many tests in UTF with LV 2012 which are testing class method VIs. We aren't doing dynamic dispatch in our unit tests however so maybe that is where the limitation is?
I'm genuinely curious as to what you have found as it may influence how I plan for future projects using the CI/UTF setup I have now.
Scott
08-12-2014 03:40 PM
Good question, I'd like some thoughts on this. The limitations we ran into were (no particular order) are from the 2012 version:
Tony
EDIT: I should probably mention that there is nothing wrong with UTF per se - its great that such a framework exists and, if the developer is not familiar with unit testing, I recommend it as a good starting point. Our needs just seemed to out-grow it. Its possible that there are strategies that help improvethe areas we outlined.
08-13-2014 08:30 AM
tyk007 wrote:
EDIT: I should probably mention that there is nothing wrong with UTF per se - its great that such a framework exists and, if the developer is not familiar with unit testing, I recommend it as a good starting point. Our needs just seemed to out-grow it. Its possible that there are strategies that help improvethe areas we outlined.
Tony,
I agree with your comments. I find myself using more JKI VI Tester for my projects. However, when the project is done for a regulated industry, then I have to use Unit Test Framework and at that point a lot of wrapper VIs have to done for the dynamic dispatch methods.
I started this community, because I believe there are a lot more people doing Unit Testing than one might think and if we start these discussions we stand a chance to getting better tools.
Thanks for joining the conversation,
Fab
08-13-2014 08:32 AM
scrook wrote:
A good next step is to automate your unit test run on a continuous integration server.
...
There are a few items in setting up Jenkins and LabVIEW that aren't totally obvious but if you have questions feel free to ask.
Scott
Scott,
Would you mind starting a new discussion/document on this group pointing people where to get started with setting up Jenkins and LabVIEW. I understand you have a full time job and this might not be possible right away, but I believe that there would be a lot of people who would benefit.
Thanks,
Fab
08-13-2014 08:34 AM
tyk007 wrote:
We have a build server we run as well (TeamCity). Much like Jenkins the build is triggered by source control check-in. We have a generic module we call GBuild that is called to build the specified project, update the build version to the build server definition, run any unit tests and execute any present VI Analyzer configuration. Messages are passed back to TeamCity so that the entire build log is captured and browsed (eg. the history of unit test results), just like any other build type such as .NET.
Tony,
Same request as for Scott, would you mind starting a discussion or document pointing us on how to get started with TeamCity?
Thanks,
Fab
08-13-2014 08:36 AM
08-13-2014 08:56 AM
Thoric wrote:
Great community, great conversation. Fab: Would you mind setting up a poll to find out which testing solutions people are choosing to adopt in their LabVIEW development? I'm interested to know just how many are not using UTF.
Done! I added UTF, JKI VI Tester, TestStand and Other:
https://decibel.ni.com/content/polls/19201