I'd like to write tests for some VIs that are inside a LabVIEW Project Library. The VIs are privately scoped, so in order to test these, I need to place the test case inside the Library.
From what I can tell, VI tester does not "see" the test if the test case is located inside a Library. If I move it out of the library into My Computer, and save all, the tests show up in VI Tester, but of course they are broken because they contain privately scoped VIs.
How should I go about testing privately scoped VIs in Libraries?
-Joe
JKI Discussion Forums
Page 1 of 1
Testings VIs inside LabVIEW Project Libraries
#2
Posted 02 November 2011 - 09:09 PM
JoeDG, on 02 November 2011 - 08:03 PM, said:
How should I go about testing privately scoped VIs in Libraries?
You can't test privately scoped VIs directly as they can never be called outside of their library. You basically have two choices:
1: Test a caller of the VI (the caller can be Public or Community scoped). The caller can be created just as a wrapper for the purpose of testing the code.
2: Change the VI under test's scope from Private to Community and add the TestCase where you want to create tests as a 'Friend' of the library.
Hope that helps!
Omar
#3
Posted 02 November 2011 - 11:04 PM
One thing I'd add (for consideration) is a link to, and quote from, a related Q&A posted on Stack Overflow:
Question: How do you unit test private methods?
Answer worth considering:
Question: How do you unit test private methods?
Answer worth considering:
Quote
If you want to unit test a private method, something may be wrong. Unit tests are (generally speaking) meant to test the interface of a class, meaning its public (and protected) methods. You can of course "hack" a solution to this (even if just by making the methods public), but you may also want to consider:
1) If the method you'd like to test is really worth testing, it may be worth to move it into its own class.
2) Add more tests to the public methods that call the private method, testing the private method's functionality. (As the commentators indicated, you should only do this if these private methods's functionality is really a part in with the public interface. If they actually perform functions that are hidden from the user (i.e. the unit test), this is probably bad).
1) If the method you'd like to test is really worth testing, it may be worth to move it into its own class.
2) Add more tests to the public methods that call the private method, testing the private method's functionality. (As the commentators indicated, you should only do this if these private methods's functionality is really a part in with the public interface. If they actually perform functions that are hidden from the user (i.e. the unit test), this is probably bad).
#4
Posted 03 November 2011 - 01:07 PM
Thanks, Omar and Jim. Jim, I think you're probably right:

I think the problem is twofold: 1) I need to be just testing the public interface to the library and 2) The public methods are overly complex, such that their private components really *need* to be tested individually. I probably need to focus my efforts on refining my object model and then my testing strategy.
I'm still pretty wet behind the ears regarding TDD, and software testing in general... I'm still trying to orient myself and get a basic understanding. Maybe with a few more course corrections, I'll begin to feel like I'm accomplishing something and not just wasting time.
Thanks guys, for providing this awesome tool!
-Joe
Quote
Something may be wrong
I think the problem is twofold: 1) I need to be just testing the public interface to the library and 2) The public methods are overly complex, such that their private components really *need* to be tested individually. I probably need to focus my efforts on refining my object model and then my testing strategy.
I'm still pretty wet behind the ears regarding TDD, and software testing in general... I'm still trying to orient myself and get a basic understanding. Maybe with a few more course corrections, I'll begin to feel like I'm accomplishing something and not just wasting time.
Thanks guys, for providing this awesome tool!
-Joe
Share this topic:
Page 1 of 1




Back to top








