Unit Testing on Real Time Targets
I’ve written a lot previously on unit testing and the value of unit tests. I try very hard to write unit tests for all my software and i try to use Test Driven Development (TDD) as much as I can. It’s not always easy.
I just started a Real Time (RT) project recently. I don’t do a whole lot of RT. I haven’t done much with it since I got into unit testing and TDD. I wanted to implement some unit tests for this project, but wasn’t quite sure how to go about that. I remembered hearing that JKI VITester wouldn’t work on RT and that Caraya would. I’ve also been meaning to play around with Caraya some more. As much as I like VI Tester, Caraya does appear to be the way of the future. I thought I would check it out.
My initial thought was to write a test exactly as I would on Windows and then run it on the RT target. I didn’t really expect it to work, but thought it might be a good place to start. Of course, it didn’t work. It generated an error.
A little google searching led to a solution. The issue is with the Caraya GUI. If you’ve done any RT stuff you will know that GUIs are limited on RT targets, so that all makes sense. The solution is to wrap your tests in a Test Suite and set the Suite to be non-interactive (ie. no GUI). That gets rid of the error.
The question then is, well how do you see your results if there is no GUI? It turns out the answer is to just have it create a report. The problem is that the report is generated on the target, so you have to figure out how to view it. As a first pass, I just SSHed into the cRIO and viewed the report in the terminal.
Once I was able to run Caraya and generate a report, I was one step closer. However, SSHing in is a bit of a pain and not everyone is comfortable on the CLI. So I wanted a better solution. The VI that runs the tests is running on the cRIO and the results file is on the cRIO so it was pretty easy to just add a little code to parse the contents of the results file and display it on the front panel.
If you need help implementing unit testing or TDD in your project, we can help! Use the button below to schedule a call.