Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an Assertable Test Actor #80

Open
vjkoskela opened this issue Jan 31, 2019 · 0 comments
Open

Create an Assertable Test Actor #80

vjkoskela opened this issue Jan 31, 2019 · 0 comments

Comments

@vjkoskela
Copy link
Member

Akka's test kit presents a reasonable set of tools for interrogating messages between actors, however, does not much in the way of capturing and asserting on the state changes within a single actor. Either Akka believes that only black-box testing should be performed or else that actors should decomposed into much smaller parts (e.g. shrinking the black box for each to the point it's almost grey).

Regardless, what we need is an test actor wrapper (TAW) that accepts a reference to the actor under test (AUT) such that when the AUT sends a message to itself it goes to the TAW. The programmer is able to register matching-predicates (much like normal actor message processing) to interrogate and asset on the message. These assertions can: 1) ensure the correct message is received; 2) transition the TAW to a different state to inform expectations of the next message or final state. Assuming the predicate does not throw (e.g. assertion failure) the TAW then forwards the message to the AUT.

Any exceptions thrown by programmer defined predicates on the TAW must be captured by the TAW. At the end of the test the programmer should "assert" on the TAW which will either pass or fail depending on: 1) whether any exceptions where thrown by predicates; 2) on custom logic asserting on the final state of the TAW and/or AUT.

Such a construct would help simplify and improve the quality of the upcoming tests in Metrics Portal where we are currently simply overriding the getSelf() method.

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

No branches or pull requests

1 participant