04-08-2009 09:57 PM
Hi all,
For example, let's say I have a state machine with 8 states. I just finished coding my first state, but I want to test it before I move on to the next state. Since I have shift registers and tunnels from the state that I just programmed, I would have to go to all the 7 states to connect all the shift registers and tunnels with dummy constants before I can test the finished state, or the program won't run for testing purposes.
Is there a better way to test a state machine one state at a time without using dummy constants, making the code in a state a subiv, etc. I want to be able to lay down my main flow, program my first state, and test my first state without messing with my other states.
Yik
04-08-2009 10:19 PM
Two choices.
1. Don't put in all the other cases for your state machine until you are ready to use them.
2. If you are using LV 8.6, you can wire the tunnels going into and out of the case structure and set them for Linked Input tunnels, and then set Create and Wire Unwired cases.
04-08-2009 10:19 PM
04-08-2009 11:31 PM
You could place the contents of a single state into a single sub-vi, this would make unit testing very easy.
Ton
04-11-2009 12:38 AM
Hi Ravens Fan,
Can you explain option 2 a bit more? Thanks!
Yik
04-11-2009 12:42 AM
I guess I can't resist using the "adding a case for each value" after I have connected my enum constant with all my cases in it to the case structure. When I do connect it, several cases would appear in the case structure, and I can't select which one to appear first.
04-11-2009 04:11 AM
Make your enum a type-def. Add one case at the time and test it.
Also see this