StateMachine icon indicating copy to clipboard operation
StateMachine copied to clipboard

Can't test transitions

Open OlivierHartmann opened this issue 6 years ago • 3 comments

Hi,

As in your readme file, I would like to test the transitions:

assertThat(transition).isEqualTo(
    StateMachine.Transition.Valid(Solid, OnMelted, Liquid, LogMelted)
)

But, the "Valid" data class has an internal constructor so I can't access it in my tests.

What should I do ? Thanks.

OlivierHartmann avatar Nov 06 '19 13:11 OlivierHartmann

I have the same problem. Would be great to be able to write unit tests.

rs-georg avatar Apr 16 '20 16:04 rs-georg

Any update on the lib to make StateMachine.Transition.Valid have a public constructor? Can't make proper tests following the readme.

fredydoss avatar Oct 31 '20 16:10 fredydoss

I believe you can do this

        assertThat(transition).isInstanceOf(StateMachine.Transition.Valid::class.java)
        assertThat(invalidTransition).isInstanceOf(StateMachine.Transition.Invalid::class.java)

and assert fromState and event from transition, although you still don't have access to toState and sideEffect

fabiofalci avatar Dec 08 '21 11:12 fabiofalci