Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
99 views
in Technique[技术] by (71.8m points)

mdriven - Setting state of a state machine for test reasons

for the implementation of a unit test I need to setup a specific state of an object. As the state is implemented with a state machine, MDriven rejects the direct assignment of the state value to the attribute.

I could maybe trigger through the complete state machine until I reach the needed state but I assume that there is an easier way to set the state to a specific value that is rather hidden as it normlaly isn't supposed to work that way.

Does anybody know how this could be done?

question from:https://stackoverflow.com/questions/65917431/setting-state-of-a-state-machine-for-test-reasons

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes - read details here https://wiki.mdriven.net/index.php/StateMachineForceMode

But basically you set the state machine for an attribute into ForceMode - after this you can freely change the state value:

self.stateMachineForceMode('State'); 
self.State:='State3'; 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...