LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unit Testing Class Methods that Use Private Data

Solved!
Go to solution

Is there a cleaner way to unit test public class methods which use state data contained in the class private ctl other than have the test VIs be members of the class itself?

 

If that is the only way, can those test VIs be stripped out of the class easily during a build in the same way you can exclude unused members from libraries?  I.e., does application builder treat lvclass files as "libraries" with that option?



I saw my father do some work on a car once as a kid and I asked him "How did you know how to do that?" He responded "I didn't, I had to figure it out."
0 Kudos
Message 1 of 6
(1,065 Views)
Solution
Accepted by topic author blackburnite

You could make the private data community scoped instead and put all of your unit tests in a library that is friends with that class.

 

I know in LabVIEW's class hierarchy classes are a child of the library class so I would expect excluding unused members would work but I don't know for sure.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 6
(1,047 Views)

Community scoped as in add accessors which are community scoped?



I saw my father do some work on a car once as a kid and I asked him "How did you know how to do that?" He responded "I didn't, I had to figure it out."
0 Kudos
Message 3 of 6
(1,014 Views)

Exactly

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 6
(1,011 Views)

Hmm, I was hoping to avoid having to make accessors for that.  It would be nice if LV classes allowed you to directly define private, public, protected, etc. class data as additional .ctls under the class which could then just be unbundled by VIs of the required scope.



I saw my father do some work on a car once as a kid and I asked him "How did you know how to do that?" He responded "I didn't, I had to figure it out."
0 Kudos
Message 5 of 6
(1,003 Views)

When you create an accessor there is a box which allows access through property nodes. You might have known that already but it's similar to what you were asking for with the unbundle.

Matt J | National Instruments | CLA
0 Kudos
Message 6 of 6
(998 Views)