glisten icon indicating copy to clipboard operation
glisten copied to clipboard

void activity methods never complete in unit tests

Open robfletcher opened this issue 10 years ago • 2 comments

If I have an activity method declared as void there seems to be no way to make its promise complete in a unit test.

For example if I have a test like:

when: workflow.start()
then: 1 * activities.step1()
then: 1 * activities.step2()

That is testing:

void start() {
  waitFor(activities.step1()) {
    activities.step2()
  }
}

Then activities.step2() is never called in the unit test. If I simply change the method definition to return any type – say boolean – and make the mock expectation return something using >> true then both activity methods do get executed.

Maybe I'm misunderstanding how this is supposed to work.

robfletcher avatar May 07 '14 15:05 robfletcher

That is exactly right. Currently, if you want to wait on an activity, it needs to return something. Flow, handles this by generating method signatures that return Promise<Void>. Glisten doesn't generate alternate signatures. We could fix this with some AST transformations, but providing return types has worked so far.

claymccoy avatar May 07 '14 15:05 claymccoy

ok, I was hoping it would pick up Promise<Void> but it's not a big deal for me to return something.

robfletcher avatar May 07 '14 15:05 robfletcher