Skip to content

Difficult to unit test workflows #68

@BrynCooke

Description

@BrynCooke

I'm using restate for the first time and the project looks great, but the ergonomics for unit testing could be improved.

There are two main issues:

  1. When defining a trait for a workflow or a service self must not be present.
#[restate_sdk::workflow]
trait MyWorkflow {
  fn do_something(); // No self
}

This means that regular mocking libraries cannot be used with these traits. The restate macro adds self which honestly is confusing. Why not just require the trait functions to take self rather than add it magically?

  1. Contex cannot be constructed and therefore any function that takes context cannot be unit tested. I want to test failure of my workflows for error handling, testcontainers is not a good fit as I will need to be able to set expectations and failures in a fine grained way.

It'd be great if Restate could provide unit test support for Context. The only solution I can see right now is to abstract Restate apis away completely in my codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions