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

Adaptive TestRunner refactoring #3055

Merged
merged 4 commits into from
Nov 13, 2020
Merged

Adaptive TestRunner refactoring #3055

merged 4 commits into from
Nov 13, 2020

Conversation

chon219
Copy link
Member

@chon219 chon219 commented Nov 11, 2020

Fixes #2959

Description

Refactored TestRunner.

Specific Changes

  • Renamed TestRunner to TestUtils to match naming in C#
  • Move initialization of ResourceExplorer to the outside of TestUtils
  • Make runTestScript static
  • Accepting adapter, middlewares as parameters in runTestScript

Testing

Updated existing tests.

@chon219 chon219 added the Area: Adaptive The issue is related to Adaptive dialogs label Nov 11, 2020
@chon219 chon219 requested a review from a team as a code owner November 11, 2020 09:51
@chon219 chon219 requested review from Stevenic and tomlm November 11, 2020 09:51
Copy link
Contributor

@joshgummersall joshgummersall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of quick suggestions, otherwise this looks good!

adapter.use(middleware);
});

adapter.onTurnError = async (context, err) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nit of mine, but this could more succinctly be written as adapter.onTurnError = (context, err) => context.sendActivity(err.message). No need to explicitly mark as async or await the result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, I tried this but the return type of onTurnError is Promise<void> and the return type of context.sendActivity(err.message) is Promise<ResourceResponse>, how can I fix the mismatch issue?


for (let i = 0; i < this.script.length; i++) {
const testAction = this.script[i];
await testAction.execute(testAdapter, bot.onTurn.bind(bot));
await testAction.execute(adapter, callback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rewrite this block to:

await Promise.all(this.script.map(testAction => testAction.execute(adapter, callback)));

I wonder if it would also be useful to use something like p-map and a configurable concurrency to control concurrent execution. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to execute all the scripts in order?

@chon219 chon219 merged commit 5906256 into main Nov 13, 2020
@chon219 chon219 deleted the zim/adaptive-test-refactor branch November 13, 2020 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Adaptive The issue is related to Adaptive dialogs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adaptive Testing TestRunner refactor
2 participants