From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Unit Test Framework with State History

Hi All,

 

Consider a very simple Set/Reset VI that has the following prototype:

Q = Set_Reset (Enable, Set, Clear)

 

The latch stores Q in an initialized shift register.

 

100% code coverage is easy with three inputs.  However, I've been unable to implement a unit test that validates this code in NI UTF.

 

For example, consider the following 3 cases :

 

  • Case 1
    • Clear = F
    • Enable = F
    • Set = F
    • (!Q)? Pass : Fail
  • Case 2
    • Clear = F
    • Enable = T
    • Set = T
    • (Q)? Pass : Fail
  • Case 3
    • Clear = F
    • Enable = F
    • Set = F
    • (!Q)? Fail : Pass

Notice that Cases 1 and 3 are the same except for the P/F criteria.

 

I could leave the shift register un-initialized.

I don't want to change the behavior of my code modules to unit test them.

 

I could use a conditional disable structure around an initialized and un-initialized feedback node and set a "UTF" symbol for the latter.

While the modification is simple enough with this code, this is simple code.  Also, I'm not really unit testing the code that will deploy.

 

I could use build a user-defined test that loops the module through all cases (retaining the module's state) and evaluates Q each time it iterates.

From what I've seen in the 2012 user-defined test example, this investment is an order of magnitude greater than building the latch itself.

 

I'd like to think I'm missing something.  What's the right way to unit test a VI that implements dynamic state?

 

Thanks for any advice,

 

Steve K

Message 1 of 3
(2,026 Views)

I stumbled upon a similar problem as I am using feedback nodes quite often to detect changes and store internal information in SubVIs. So there is no simple solution?

0 Kudos
Message 2 of 3
(1,916 Views)

I've not heard or seen of one 😞

 

Please let me know if you do.

 

-Steve K

0 Kudos
Message 3 of 3
(1,902 Views)