Skip to content

StateMachineActions: Support func(rapid.TB) actions#66

Merged
flyingmutant merged 3 commits intoflyingmutant:masterfrom
prashantv:prashant/state-machine-rapid-tb
Apr 1, 2024
Merged

StateMachineActions: Support func(rapid.TB) actions#66
flyingmutant merged 3 commits intoflyingmutant:masterfrom
prashantv:prashant/state-machine-rapid-tb

Conversation

@prashantv
Copy link
Contributor

This allows reuse actions from normal tests that use testing.TB.

This is helpful for tests where there may be very specific test scenarios where some logic is abstracted into a common action.

@flyingmutant
Copy link
Owner

I usually write StateMachine types specifically to use them in state machine tests, so the only methods they have are the methods that StateMachineActions expect. These methods can call any kind of helpers required. Can you provide an example explaining why a StateMachine type would have methods for other scenarios as well?

@prashantv
Copy link
Contributor Author

The primary motivation is to reuse actions and other test helpers across rapid tests, as well as plain tests using *testing.T or *testing.B.

In my specific scenario, I wanted to test a very specific set and order of actions in a normal test, and guarantee that runs as part of every run. This was also useful to develop new actions by using a standard test with a specific set of actions.

A couple of other benefits:

  • More complex test scenarios can reuse rapid.TB actions without additional wrapper functions
  • Benchmarks can reuse actions
  • Test helpers can be written using rapid.TB that allow reuse across actions and normal *testing.T tests

For cases where a state machine is only used for rapid tests, it's not necessary, but it helps with reusing the same type in other tests.

This allows reuse actions from normal tests that use `testing.TB`.

This is helpful for tests where there may be very specific test
scenarios where some logic is abstracted into a common action.
@prashantv prashantv force-pushed the prashant/state-machine-rapid-tb branch from 2a4c7fe to 1e1ff53 Compare March 31, 2024 16:45
@prashantv prashantv force-pushed the prashant/state-machine-rapid-tb branch from 1e1ff53 to c9e8de3 Compare March 31, 2024 16:50
@flyingmutant flyingmutant merged commit 34cb5b2 into flyingmutant:master Apr 1, 2024
@flyingmutant
Copy link
Owner

Merged, thanks!

@prashantv prashantv deleted the prashant/state-machine-rapid-tb branch April 1, 2024 18:45
@prashantv
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants