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

Support multiple assertion libraries/test runners for the TestAdapter class #100

Closed
microsoftly opened this issue Feb 24, 2018 · 6 comments
Assignees
Labels
P3 P3 Work Item
Milestone

Comments

@microsoftly
Copy link

Users of the BotTester framework found it useful to be able to use different testing frameworks when running their tests. While its internal chai solution would throw an error when assertions failed, users still requested the ability to have support for multiple libraries.

For reference, here's the issue thread on the BotTester framework repo.

@Stevenic Stevenic self-assigned this Feb 26, 2018
@Stevenic
Copy link
Contributor

If you have some thoughts for how to achieve that I'd love to see a PR. Look at the TestAdapter in the M2 branch though.

@Stevenic
Copy link
Contributor

Was just working on getting better code coverage on the TestAdapter and we'll need to do some re-factoring to support alternate frameworks. Should be just a matter of abstracting out the adapters internal calls to assert. Again open to feedback on how to approach this.

@microsoftly
Copy link
Author

I would recommend something like the implementation in the BotTester framework; define an interface for an expectation, e.g.

export interface IExpectation {
    notToBeEmpty(): void;
    toEqual(value: {}): void;
    toInclude(value: {}): void;
    toBeTrue(): void;
    toDeeplyInclude(value: {}): void;
}

Then for each assertion library, implement accordingly. Using examples from my repo:

  1. chai
  2. ava (small note on this one, I used a hack to get it out quickly for user consumption, it actually uses the ChaiExpectation under the hood)

For some frameworks like ava, you will need to expose a test context. These can be passed in when constructing the test adapter.

Lastly, the end user needs a way of defining which library to use (you can always default to assert or some other frequently used library like chai). This can be done by passing in test options to the test Object, all with standard defaults. To go even further, a config file that exposes test options can be useful as well (e.g. set timeout, default address, test framework, etc ...) can give the end user many options for how to configure their tests.

@microsoftly
Copy link
Author

If you're okay with this approach, I can help with the dev

@Stevenic
Copy link
Contributor

@microsoftly if you'd like to take a crack at re-working the TestAdapter class to support the above abstraction I'd say go for it.

@Stevenic Stevenic added the P3 P3 Work Item label Apr 17, 2018
@Stevenic Stevenic added this to the Release milestone Apr 17, 2018
@Kaiqb Kaiqb added the customer-reported Issue is created by anyone that is not a collaborator in the repository. label Jul 23, 2019
@sgellock sgellock removed the customer-reported Issue is created by anyone that is not a collaborator in the repository. label Aug 8, 2019
@Stevenic
Copy link
Contributor

Closing old issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 P3 Work Item
Projects
None yet
Development

No branches or pull requests

4 participants