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