As I have been doing more and more Unit Testing and Continuous Integration, I have often wondered about automating testing of built code. There are promising tools out there for testing built Win32 apps, such as WinAppDriver. There is also Selenium for testing webapps, so if you are into the new WebVIs in NXG, that might be an option. However each of those requires learning some new tools (at least for me), and I really haven’t seen any examples of people using these to test apps built in LabVIEW. If you have please let me know.
What I have found though is that there are some ways to take existing unit tests and run them against “built” code in the form of source distributions, VIPM builds, and ppls using the Replace Item With method. This ProjectItem method was officially introduced in LV 2019. If you build your Win32 app mostly out of ppls then this might be an ok substitute.
Here is how I use it.
- First I run my normal unit tests.
- Then I build my source distribution/vip/ppl.
- If it’s a vip I install it.
- Then I run a scripting VI that loads all my unit tests into a project. It finds the library I want to replace and replaces it with the built library or packed library and saves them.
- I run the unit tests again
- I revert all my tests back
That is how I verify that everything got linked/built/installed correctly. Ideally you would run steps 3-6 on a fresh VM. That way you can detect if you have missing dependencies. One caveat is that if you are testing a source distribution or VIPM build, you need to make sure that you rename the library. This is easy to do in VIPM. If you try to replace a library with another with the exact same name, but at a different location on disk, it won’t work. If you are trying to figure out why just remember how LabVIEW does namespacing. This is not an issue with ppls because A.lvlib <> A.lvlibp.
The best part about this approach: I only have to write the unit tests once!
What are you all using to test built applications? Who’s reusing tests for their source distirbutions, vips, or ppls? Anyone figured out how to test Win32 apps yet?